N
Nuxt5mo ago
lav

Client-Side Middleware

Hello, I was wondering if it is possible to have a middleware runs only client-side and redirect if something is not set for example in local storage, etc.
export default defineNuxtRouteMiddleware((to, from) => {
if (import.meta.server) return;

if (to.path === '/test') {
return navigateTo('/');
}
});
export default defineNuxtRouteMiddleware((to, from) => {
if (import.meta.server) return;

if (to.path === '/test') {
return navigateTo('/');
}
});
Right now I am doing this test and I return if it is server let's say I have to access local storage, but I still see the test page beign render and after it redirects is there a way to fix this? Thanks!
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server