This is a boilerplate for Next.js applications with Supabase authentication. It includes a complete authentication flow with protected routes and middleware.
- 🔐 Authentication with Supabase
- 🛡️ Protected routes with middleware
- 🎨 Styled with Tailwind CSS
- 📱 Responsive design
- 🔄 Type-safe with TypeScript
-
Clone this repository
-
Install dependencies:
npm install
-
Create a Supabase project at https://supabase.com
-
Copy
.env.local.example
to.env.local
and update with your Supabase credentials:cp .env.local.example .env.local
-
Update the environment variables in
.env.local
:NEXT_PUBLIC_SUPABASE_URL=your-project-url NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
-
Run the development server:
npm run dev
-
Open http://localhost:3000 with your browser to see the result.
-
/app
- Next.js 13 app directory-
/auth
- Authentication pages (login, callback) -
/dashboard
- Protected dashboard page
-
-
/lib
- Utility functions and configurations-
supabase.ts
- Supabase client configuration
-
- Users can sign in/up through the
/auth/login
page - After successful authentication, they are redirected to
/dashboard
- Protected routes are handled by the middleware
- Unauthenticated users are redirected to the login page
- Authenticated users are redirected away from auth pages