Airwire with NextJS/React
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?
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.
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.
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.
+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