-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Next.js auth integration package POC #3
base: feat/supabase
Are you sure you want to change the base?
Conversation
utils/supabase/client.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only needed to add the generated types to the client and/or to pass special options to Supabase Client.
For the types I imagine we could leverage TypeScript module augmentation to set the Database type directly on the client exported by @supabase/auth/next/client
. 🤔
@@ -42,7 +42,7 @@ export function UserMenu({ user }: UserMenuProps) { | |||
'use server' | |||
const supabase = createClient() | |||
await supabase.auth.signOut() | |||
redirect('/login') | |||
redirect('/') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the middleware takes care of redirecting to the login page if the user is not authenticated. 👍
if (session) { | ||
redirect('/') | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's better to centralize this logic of public vs protected pages in the middleware.
This PR demonstrates what Supabase Auth integration would be like using https://www.npmjs.com/package/@supabase-labs/nextjs