@netisu/chimera
v1.2.9
Published
Use your AdonisJS named routes in your inertia frontend.
Maintainers
Readme
@netisu/chimera
Netisu presents.....
Chimera 🦁 🐍 🐐
Use your AdonisJS named routes in your inertia frontend.
Installation
node ace add @netisu/chimera
node ace configure @netisu/chimeraSetup
Register a Named Route
Create a named route in your start/routes.ts file:
Route.get('users/:id', () => {
...
}).as('users.show');Client-Side Usage
Getting the routes in your frontend
Compile your routes file by running
node ace chimera:generateBy 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 { route } from 'resources/js/chimera'
route('users.index') // => `/users/1`
/**
* You can also pass path params as an array and they will populated
* according to their order:
*/
route('users.show', { id: 1 }) // => `/users/1`Checking the Current Route
import { current } from 'resources/js/chimera'
current('dashboard')