Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
15 views2 pages

Hybrid Router

The document provides a guide for setting up Server-Side Authentication in Next.js, detailing the use of both the App Router and Pages Router. It outlines where to import the createClient utility for different components and emphasizes the need for a middleware.ts file for session management in the App Router. Users can utilize both routing strategies within the same application.

Uploaded by

Felipe Montero
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views2 pages

Hybrid Router

The document provides a guide for setting up Server-Side Authentication in Next.js, detailing the use of both the App Router and Pages Router. It outlines where to import the createClient utility for different components and emphasizes the need for a middleware.ts file for session management in the App Router. Users can utilize both routing strategies within the same application.

Uploaded by

Felipe Montero
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

DOCS Search

Auth

Auth Server-Side Rendering Next.js guide

Setting up Server-Side Auth for Next.js

Next.js comes in two flavors: the App Router and the Pages Router. You can set up Server-Side
Auth with either strategy. You can even use both in the same application.

App Router Pages Router Hybrid router strategies

You can use both the App and Pages Routers together.

Follow the instructions for both the App and Pages Routers. Whenever you need to connect to
Supabase, import the createClient utility that you need:

Router Code location Which createClient to use

App Router Server Component, Server Action, or Route Handler server.ts

Client Component client.ts

Pages Router getServerSideProps server-props.ts

getStaticProps static-props.ts

Component component.ts

API route api.ts

Remember to create the middleware.ts file for the App Router so the session refreshes for App
Router pages.

Edit this page on GitHub


Need some help? Contact support
Latest product updates? See Changelog
Something's not right? Check system status

© Supabase Inc

Contributing

Author Styleguide

Open Source

SupaSquad

Privacy Settings

You might also like