jetstream: Uncaught ReferenceError: route is not defined

  • Jetstream Version: 1.6.1
  • Jetstream Stack: Inertia
  • Laravel Version: 8.15.0
  • PHP Version: 7.4.12
  • Database Driver & Version: mysql v8.0.20

Description: Login page displays error on the web console. This message disappears once a user is logged in. Uncaught ReferenceError: route is not defined at Module../resources/js/app.js

Steps To Reproduce:

  1. laravel new sample
  2. composer require laravel/jetstream
  3. php artisan jetstream:install inertia (or with --teams)
  4. npm install && npm run dev
  5. php artisan migrate
  6. php artisan serve
  7. Visit Login, Registration, or Forgot Password page to view error on console.

UncaughtReferenceErrorRoute

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 15 (3 by maintainers)

Most upvoted comments

I had this issue myself when installing Jetstream with Inertia for the first time where there were a few hiccups along the way i.e. the installer didn’t work as expected because of my local environment so I had to install a few dependencies manually.

For me once I’d created an account and was taken to /dashboard the issue was clearer since I could only see @routes output in the browser. This is because the @routes blade directive wasn’t available from the tightenco/ziggy and should’ve been added by the installer (but it wasn’t because of those hiccups) https://github.com/laravel/jetstream/blob/daba98419164024e2c071f5547dd5569aba69d98/src/Console/InstallCommand.php#L249

If that’s the same for you just do composer require tightenco/ziggy and it should resolve your issue.

The Laravel Jetstream login, two-factor login, registration, password reset, and email verification views have guest.blade.php as the base layout while everything else uses app.blade.php. In the guest.blade.php the @routes directive is missing but the mix(‘js/app.js’) depends on it. I tried adding it to the guest.blade.php template but now i get a TypeError MissingRoutesDirective CannotReadPropertyOfNull