airwire icon indicating copy to clipboard operation
airwire copied to clipboard

Airwire with NextJS/React

Open mackensiealvarezz opened this issue 4 years ago • 4 comments

Greetings,

I love the idea of this being a REST API Wrapper component based. Is It possible to use something like this with NextJS? Where the backend and the frontend might be in different servers?

mackensiealvarezz avatar May 25 '21 10:05 mackensiealvarezz

Definitely. As long as you can find the type definitions in your local build, it'll work correctly.

And even without that, it'd work. The TS files are just for good syntax, the package works without them just fine.

The server communication itself doesn't require that they're on the same server.

stancl avatar May 25 '21 10:05 stancl

Thank you for explaining how the package works!

It looks like for the frontend, the route is hardcoded. I can probably create a PR to turn this into an environment variable? https://github.com/archtechx/airwire/blob/cdc9f326115899d6c7cc49ef2748818c1b2cea72/resources/js/index.ts#L255

Also, would it be possible to have the frontend separated into a npm package? Because currently if the backend and frontend are on different projects how would the frontend have access to Airwire.

mackensiealvarezz avatar May 27 '21 02:05 mackensiealvarezz

It's public, you can just modify it using Airwire.route = 'https://anything/foo'.

There won't be an npm package due to the complexity of managing versions. I need the PHP and JS to be in sync.

I suggest installing the package via composer and just importing it from vendor by path.

stancl avatar May 27 '21 08:05 stancl

+1 to have the frontend separated into a npm package.

My reason is: I'm implementing the backend/protocol in Java. Take a look to the code here: @SMontiel/cable

SMontiel avatar Jul 10 '21 20:07 SMontiel