Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Tii's avatar
Level 15

route not defined with Inertia SSR

I'm not quite sure where to put this.

I just verified that its not just my app.

I installed a fresh Laravel project with Laravel Breeze using Vue with Inertia, Inertia SSR and TypeScript.

Then I added a console.log(route('profile')) in my Welcome.vue files <script setup> section. compiled everything with npm run build, started the ssr server with php artisan inertia:start-ssr, disabled JavaScript in my browser and reload the page.

The result is always the same:

It's always ReferenceError: route is not defined.

That's the problem I have in my application too. With JavaScript running from the browser: No problems at all. Everything works fine. But without JavaScript, so it definitely comes from the SSR server: route is not defined.

I'm a litte overwhelmed with this... Someone any ideas?

I crossposted this to https://github.com/inertiajs/inertia-laravel/issues/670, because I assume it's a bug at least in the Laravel Breeze template.

0 likes
1 reply
Tii's avatar
Level 15

I found a workaround by doing this in every component I need routes:

import {route as ziggyRoute} from "ziggy-js";
const route = inject<typeof ziggyRoute>("route")!;
1 like

Please or to participate in this conversation.