Lifetime access is $100 off. Ends this week.Join here →

Hide exposed routes when using Ziggy

Hey everyone 👋

Have you guys tried hiding the generated routes of Ziggy when using Inertia?

Typical setup

    <!-- Scripts -->
<body class="font-sans antialiased">

If you're using php artisan ziggy:generate how do you set it up properly?

whoami (Daryl)
whoami (Daryl)


That's what that library does. It. exposes your routes.

I may have misguided you previously in your other thread. You don't need to actually use the ziggy-js library.

Ziggy Installation

In your HandleInertiaRequests middleware, just use the following.

            'ziggy' => function () use ($request) {
                return array_merge((new Ziggy())->toArray(), [
                    'location' => $request->url(),

In your app.js, you still need the following.

import { ZiggyVue } from "ziggy";

            .use(ZiggyVue, Ziggy)

In your ssr.js, you need the following.

import { ZiggyVue } from "ziggy";

                .use(ZiggyVue, {

The route helper should be globally available.

php artisan ziggy:generate

You don't need to use this either.

You can also delete the ziggy.js file in your resources/js folder.

whoami (Daryl)
whoami (Daryl)

Hey Haz,

Thank you so much for pointing that out, will update my code 🎉