Skip to content

Repository files navigation

@netisu/chimera

code style: prettier

Netisu presents.....

Chimera 🦁 🐍 🐐

Use your AdonisJS named routes in your inertia frontend.

Installation

node ace add @netisu/chimera

node ace configure @netisu/chimera

Setup

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: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 { 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')

Releases

Packages

Used by

Contributors

Languages