Zeeeth
Zeeeth
Explore posts from servers
NNuxt
Created by Zeeeth on 10/1/2024 in #❓・help
Add data to store on Page Refresh
Lets say i have an authentication, when the user login i get a token and i store that in a session cookie. I also add the user-information to a Pinia UserStore. All good. But when the user refreshes the page i would need to use that session cookie to first fetch the current user from the API and once again populate the UserStore with the user data. Where do i place this code? I've seen examples on both just placing that code in App.vue, or creating a plugin to populate the data. Is there any Best Practice for doing this SSR-friendly? Placing it directly in App.vue seem like a OK solution, but feels like it very fast could grow a bit depending on the session data that need to be fetched.
8 replies
NNuxt
Created by Zeeeth on 9/30/2024 in #❓・help
Initializing a pinia store
When / Where would be the best practice / optimal place to initialize a pinia store? is app.vue the place to be or would you create one or multiple plugins to handle this?
6 replies
NNuxt
Created by Zeeeth on 4/24/2023 in #❓・help
Dynamic route in nuxtRouteMiddleware
So i'm experimenting with dynamic routes and i try to create a Dynamic Route within a nuxtRouteMiddleware that matches the current path. The idea is that there will be some kind of API-request that verifies the existence of the route, and then it is created on the fly and then rendered. I have made a small stackblitz that demonstrates what i want to do and the router.addRoute works fine, but the page is actually not rendered. So... when i open the browser at /test-dynamic-route i want the pages/dynamicPage.vue to be rendered but i'm kind of stuck now. I hope someone have an idea of what to do, thanks! https://stackblitz.com/edit/github-1cetba?file=middleware/routeGuard.global.ts
2 replies