Once user is authenticated, you can build private routes like a user dashboard, account, etc.
If you want to make protected API calls, follow this tutorial.
The middleware.ts ensures any pages & subpages are private. If the user is not authenticated, he'll be redirected to the login page.
Here's an example of a simple user dashboard showing private user data in a server component:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 import { createClient } from "@/utils/supabase/server"; import UsersTable from "@/components/ui/dashboard/UsersTable"; export default async function Users() { const supabase = createClient(); const { data, error } = await supabase.from('users').select("*"); if (error) { throw new Error(error.message); } return ( <UsersTable data={data} /> ); }