Skip to content
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

Draft
wants to merge 11 commits into
base: feat/supabase
Choose a base branch
from

Conversation

jgoux
Copy link
Collaborator

@jgoux jgoux commented Sep 18, 2024

This PR demonstrates what Supabase Auth integration would be like using https://www.npmjs.com/package/@supabase-labs/nextjs

Copy link
Collaborator Author

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('/')
Copy link
Collaborator Author

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. 👍

Comment on lines -9 to -11
if (session) {
redirect('/')
}
Copy link
Collaborator Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant