Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using router.on triggers ReferenceError: document is not defined when using SSR #2149

Open
harmendv opened this issue Dec 20, 2024 · 1 comment

Comments

@harmendv
Copy link

Version:

  • @inertiajs/vue3 version: ^2.0.0

Describe the problem:

When I use the code snippet from the documentation (see below), I encounter a ReferenceError: document is not defined when working with SSR.

import { router } from '@inertiajs/vue3'

router.on('start', (event) => {
  console.log(`Starting a visit to ${event.detail.visit.url}`)
})

Steps to reproduce:

  • Add the code snippet to the <script setup> section of a Vue page. (Works with the default laravel breeze scaffold with SSR)
  • Build the project.
  • Start the SSR server.
  • Navigate to the page containing the code snippet.
@RobertBoes
Copy link
Contributor

This should've been fixed in #1715, but I see with 2.x these changes have been reverted due to refactors, I'll look at sending in another PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants