Closed Supavasinan closed 2 weeks ago
Hey sorry, was a bit busy.
There are multiple ways to achieve this, if it's the immediate child that needs it, pass it as a prop, otherwise add file to your repo: components/auth-provider.tsx
components/auth-provider.tsx
Then wrap the pages that require auth with the AuthProvider, like shown:
https://github.com/TheBinaryGuy/next-hono-lucia/blob/28eecbc53acd18f293e69c72f616493105e0b0ec/src/app/page.tsx
If it's too much to wrap all pages with the auth provider, use a route group and add a layout file with the auth stuff.
And the all the children client components can access the user via the useAuth hook, like this.
useAuth
https://github.com/TheBinaryGuy/next-hono-lucia/blob/28eecbc53acd18f293e69c72f616493105e0b0ec/src/app/client-user.tsx
Hope this helps, added this into the template as well :)
Hey @Supavasinan, I'm closing this issue now, if you feel like the above doesn't address your issue, feel free to reopen it :)
Hey sorry, was a bit busy.
There are multiple ways to achieve this, if it's the immediate child that needs it, pass it as a prop, otherwise add file to your repo:
components/auth-provider.tsx
Then wrap the pages that require auth with the AuthProvider, like shown:
https://github.com/TheBinaryGuy/next-hono-lucia/blob/28eecbc53acd18f293e69c72f616493105e0b0ec/src/app/page.tsx
If it's too much to wrap all pages with the auth provider, use a route group and add a layout file with the auth stuff.
And the all the children client components can access the user via the
useAuth
hook, like this.https://github.com/TheBinaryGuy/next-hono-lucia/blob/28eecbc53acd18f293e69c72f616493105e0b0ec/src/app/client-user.tsx
Hope this helps, added this into the template as well :)