How to setup Ziggy on Laravel/Inertija/Vite/Vue

Dr. Adam Nielsen
2 min readNov 14, 2023

The official Ziggy documentation is very detailed and covers many situations. But, it can be tough to find the exact help you need for your own setup. Here is the setup if you are on a fresh Laravel 9 application together with Vite, Vue, Intertija. Roadmap:

  1. Install composer package
  2. Add @routes helper in your blade.
  3. Add ziggy-js alias
  4. Load ZiggyVue
  5. Celebrate

Let’s go into details:

Install composer Package

Install like this (no npm package or anything else required):

composer require tightenco/ziggy

Add @routes helper

Add ziggy-js alias

Add a ziggy-js in your vite.config.js:

Here the code from the screenshot for copy & paste:

resolve: {
alias: {
'ziggy-js': path.resolve('vendor/tightenco/ziggy/dist/vue.es.js'),
}
},

Import ZiggyVue

Add .use(ZiggyVue) to your VueApp constant in you app.js

And that is the entire setup. You can use “route” helper anywhere within your Vue components, without importing it.

Also be aware, there is no need to run `php artisan ziggy:generate` in setup.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Dr. Adam Nielsen
Dr. Adam Nielsen

Written by Dr. Adam Nielsen

PHD in math. and Laravel / Vue Full-Stack-Developer

Responses (1)

Write a response

at this time 2024-10-11 path to resolve is path.resolve('vendor/tightenco/ziggy/dist/index.esm.js')