Alireza
Difference between server plugin and server route middleware
@kapa.ai
Could you elaborate on this part?
The key difference between this and middleware is that server plugins run before the Vue app is created, while middleware runs as part of the Vue routing process. This makes server plugins suitable for early request processing and setting up server-specific state or services.How you can run composables in the Nuxt plugins before the Vue app is created?
20 replies
Difference between server plugin and server route middleware
@kapa.ai Can you elaborate on this?
Using a Nuxt server plugin (/plugins/location.server.ts) would run the location-fetching code when the Nuxt app initializes on the server.The initialization of the Nuxt app on the server, does it happen on each request to server? or only once when the server starts using
nuxi preview
20 replies
Difference between server plugin and server route middleware
@kapa.ai I think there is a misunderstanding. I did not mean Nitro server plugin. I meant a regular nuxt plugin with
.server
suffix.. You can suffix a plugin with .server
to tell Nuxt to rin the plugin on server only.20 replies
SSR friendly usePreviousRoute()?
@kapa.ai Yeah, looks like useState is a better approach.
The problem with the router is when:
1. user navigates from category to article
2. we have the previous route
3. the for some reason user reloads the page, and we lose the previous.
So we better use something that keeps it as a state that is presisted somehow?
24 replies