I want to use Adonis with a Vue3 SPA. Is there a way I could use my adonisJS named routes in the vue client (a package similar to Ziggy for Laravel)? Any pointers will be much appreciated.
Asked
Active
Viewed 235 times
1 Answers
1
Older question, but everyone else that lands here, there's actually a package called Adonis Stardust inspired by Ziggy for Laravel:
https://github.com/eidellev/adonis-stardust
After you install and configure it running:
npm i @eidellev/adonis-stardust
node ace configure @eidellev/adonis-stardust
All you have to do is add @routes() to your app.edge before your JS is imported, and in your main.js import it and execute initRoutes().
To access it on the client side calling:
import { stardust } from '@eidellev/adonis-stardust';
let route = stardust.route('customers.show', { customer: 'cust_1234' });
The route variable will return /customers/cust_1234 (or however you have set it up in the back).

DLK
- 310
- 1
- 2
- 14