Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Ellie Rider's avatar

Inertia + API resources

Can anyone point me to some good resources on how to structure an Inertia/Laravel/Vue 3 app to also be able to support an API to be used by a mobile app and browser extension?

How can I get the most re-use out of my code? I don't want to paint myself into a corner.

0 likes
2 replies
Sinnbeck's avatar

I don't know of any resources specifically for this but I can give you some inspiration.

First of you cannot reuse your routes. That means you need to encapsulate your logic for easy reuse. For this i would use actions. Next i would use api resources that can be used to format the json structure in a way that works for both inertia and your mobile api.

This means you controller methods can be reduced to a few lines. First you get data with the action. Then you format it with the resource, and then you return it

https://freek.dev/1371-refactoring-to-actions

Sinnbeck's avatar

You also need to consider if inertia is a good fit if you need to manage two seperate set of routes for every single feature in your app.

Please or to participate in this conversation.