I’m mainly backend dev and worked for years with frontend/backend communicating through an API layer.
Now I have an Inertia project where I often feel like that I’m working against the framework. I have some concerns where I want to know what the best practice way of handling such scenarios is.
-
Dealing with large Datasets
I have multiple pages where I have a lot of data that gets transmitted to Frontend. The docs don’t give much info about this but what’s the best way of dealing with this. Especially on subsequent data reloads (ie after form submission or router.reload). I know I can provide the ‘only’ parameter but that still has to run the controller function and thus, all the other code not necessarily required for that few requested parameters. The only current solution I see would be a closure. But this doesn’t feel very “finished” as it forces a lot of duplicate code and overall makes the code look ugly.
2. Dynamic requests
Let’s say there is some button that the user can interact with that triggers something beyond CRUD. Currently in the codebase these are done with plain axios requests. But those completely ignore the Inertia ecosystem. I feel like that’s kind of the wrong approach of doing it. The controllers on the backend side are therefore mixed with inertia and json responses.
3. Error handling
This is currently all over the place. Inertia has a beautiful way of displaying errors. Because dynamic requests aren’t within the ecosystem, it doesn’t apply to those requests. I have my own complete approach of correcting this but I wanted to hear if there is maybe already a best-practice way of doing this. This is also a general Laravel concern. Coming from Spring, everything error related is done through exceptions. Does that fit for Laravel too?