Skip to content

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

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.

2 participants