Netisu presents.....
Use your AdonisJS named routes in your inertia frontend.
node ace add @netisu/chimera
node ace configure @netisu/chimera
Create a named route in your start/routes.ts file:
Route.get('users/:id', () => {
...
}).as('users.show');
Compile your routes file by running
node ace chimera:generate
By default it will export your routes at
resources/js/chimera.ts
but you can change this inside of the chimera config (at config/chimera.ts).
Now you can use the Chimera
helper to access your adonis routes:
import Chimera from 'resources/js/chimera';
Chimera.route('users.index'); // => `/users/1`
/**
* You can also pass path params as an array and they will populated
* according to their order:
*/
Chimera.route('users.show', { id: 1 }); // => `/users/1`
import Chimera from 'resources/js/chimera';
Chimera.current('dashboard');