Creating a Supabase client for SSR
Install Supabase packages#
The ssr
package configures Supabase to use Cookies, which is required for server-side languages and frameworks.
_10npm install @supabase/ssr @supabase/supabase-js
Set environment variables#
Create a .env.local
file in your project root directory. You can get your SUPABASE_URL
and SUPABASE_ANON_KEY
from inside your Supabase project's dashboard.
Creating a client#
Creating a Supabase client with the ssr
package automatically configures it to use cookies. This means your user's session is available throughout the entire Next.js stack - client, server, App Router, Pages Router. It just works!
Next steps#
- Implement Authentication using Email and Password
- Implement Authentication using OAuth
- Learn more about SSR