steven-tey / precedent

An opinionated collection of components, hooks, and utilities for your Next.js project.
https://precedent.dev
MIT License
4.65k stars 406 forks source link

Create use-session.ts (#1) #79

Closed Fr3akyMurk closed 2 months ago

Fr3akyMurk commented 6 months ago

Help with making pages like dashboards, settings, custom login pages and more by grabbing the session of a already logged in user.

Eliminates the problems of "Session" wrapper or other workarounds. Can be called from clients to get a session, this however is slow and should not be used for things that needs the session immediately like the navbar.

Added functionality to return null, otherwise parent code will never do anything when there is no user logged in. (This is an issue if parent code checks for a session, if there is none then redirect to a login page.)

vercel[bot] commented 6 months ago

@Fr3akyMurk is attempting to deploy a commit to the Elegance Team on Vercel.

A member of the Team first needs to authorize it.

steven-tey commented 2 months ago

you should be able to get this from next-auth's useSession hook