Skip to content
This repository has been archived by the owner on Dec 12, 2023. It is now read-only.

Add an example to use defineNuxtRouteMiddleware() in middleware/ to readme.md? #69

Open
BananaAcid opened this issue Feb 15, 2023 · 1 comment
Labels
question Further information is requested

Comments

@BananaAcid
Copy link

BananaAcid commented Feb 15, 2023

Ask your question

Could you add an example on how to access the session using a nuxt3 route middleware with defineNuxtRouteMiddleware() to the readme?

Additional information

referencing https://nuxt.com/docs/api/utils/define-nuxt-route-middleware#redirection

@BananaAcid BananaAcid added the question Further information is requested label Feb 15, 2023
@angelhdzdev
Copy link

angelhdzdev commented Jul 1, 2023

image

Same session hooks can be used in the server (backend) and in the client (frontend), so you can use them in the front in a nuxt route middleware.

So:

export default defineNuxtRouteMiddleware(async () => {
  const { session, refresh, update, reset } = await useSession()

})

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants