Skip to content

πŸš€ Production-ready Next.js 14 + Supabase template with authentication, real-time features, and beautiful UI. Includes TypeScript, Tailwind CSS, and shadcn/ui components.

License

Notifications You must be signed in to change notification settings

Elhard1/next-js-supabase-website-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Next.js + Supabase Template

Next.js 14 + Supabase Website Template

πŸš€ Production-Ready β€’ πŸ”’ Type-Safe β€’ πŸ’Ž Feature-Rich

Features β€’ Live Demo β€’ Quick Start β€’ Supabase Features β€’ Deploy

✨ Features

  • πŸ—οΈ Next.js 14 - Latest features including App Router and Server Components
  • πŸ” Supabase - Production-ready backend with:
    • πŸ”‘ Authentication (Email, Social Providers)
    • πŸ“¦ Database (PostgreSQL)
    • πŸ—‚οΈ Storage (Large Media Files)
    • πŸ”„ Real-time Subscriptions
    • πŸš€ Edge Functions
  • 🎨 Modern Stack:
    • πŸ’… Tailwind CSS - Utility-first CSS
    • 🧱 shadcn/ui - Re-usable components
    • πŸ” TypeScript - Type safety
    • πŸ“± Responsive Design
    • 🌐 SEO Optimized

🎯 Quick Start

1️⃣ Clone & Install

# Clone the repository
git clone https://github.com/yourusername/next-js-website-template.git

# Navigate to the project
cd next-js-website-template

# Install dependencies
npm install

2️⃣ Set Up Supabase

  1. Create a Supabase project at supabase.com
  2. Copy your project credentials
  3. Set up environment variables:
cp .env.example .env.local
  1. Fill in your Supabase credentials in .env.local

3️⃣ Run Development Server

npm run dev

Visit http://localhost:3000 πŸŽ‰

πŸ”₯ Supabase Features

Authentication

// Sign Up
const { data, error } = await supabase.auth.signUp({
  email: 'user@example.com',
  password: 'password123'
})

// Sign In
const { data, error } = await supabase.auth.signInWithPassword({
  email: 'user@example.com',
  password: 'password123'
})

// Social Auth (GitHub example)
const { data, error } = await supabase.auth.signInWithOAuth({
  provider: 'github'
})

Database Operations

// Create
const { data, error } = await supabase
  .from('todos')
  .insert({ task: 'Buy milk', user_id: user.id })

// Read
const { data, error } = await supabase
  .from('todos')
  .select('*')
  .eq('user_id', user.id)

// Update
const { data, error } = await supabase
  .from('todos')
  .update({ completed: true })
  .eq('id', todoId)

// Delete
const { data, error } = await supabase
  .from('todos')
  .delete()
  .eq('id', todoId)

Real-time Subscriptions

// Subscribe to changes
const subscription = supabase
  .channel('todos')
  .on('postgres_changes', 
    { event: '*', schema: 'public', table: 'todos' },
    (payload) => {
      console.log('Change received!', payload)
    }
  )
  .subscribe()

File Storage

// Upload file
const { data, error } = await supabase.storage
  .from('avatars')
  .upload('public/avatar1.png', file)

// Download file
const { data, error } = await supabase.storage
  .from('avatars')
  .download('public/avatar1.png')

πŸ“ Project Structure

β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/                 # App Router Pages
β”‚   β”‚   β”œβ”€β”€ (auth)/         # Authentication Routes
β”‚   β”‚   β”œβ”€β”€ dashboard/      # Protected Routes
β”‚   β”‚   └── page.tsx        # Home Page
β”‚   β”œβ”€β”€ components/         # React Components
β”‚   β”‚   β”œβ”€β”€ ui/            # UI Components
β”‚   β”‚   └── auth/          # Auth Components
β”‚   β”œβ”€β”€ lib/               # Utilities
β”‚   β”‚   β”œβ”€β”€ supabase.ts    # Supabase Client
β”‚   β”‚   └── utils.ts       # Helper Functions
β”‚   └── types/             # TypeScript Types
β”œβ”€β”€ public/                # Static Assets
└── ...config files

πŸ”§ Advanced Configuration

Database Schema

-- Example schema for a basic todo app
create table public.todos (
  id uuid default uuid_generate_v4() primary key,
  user_id uuid references auth.users not null,
  task text not null,
  completed boolean default false,
  created_at timestamp with time zone default timezone('utc'::text, now())
);

-- Enable Row Level Security
alter table public.todos enable row level security;

-- Create policies
create policy "Users can view their own todos" 
  on todos for select using (auth.uid() = user_id);

Storage Buckets

  1. Create a new bucket:
insert into storage.buckets (id, name)
values ('avatars', 'avatars');
  1. Set up storage policies:
create policy "Avatar images are publicly accessible"
  on storage.objects for select
  using ( bucket_id = 'avatars' );

create policy "Users can upload their own avatar"
  on storage.objects for insert
  with check ( bucket_id = 'avatars' AND auth.uid() = owner );

πŸš€ Deployment

Deploy to Vercel

  1. Push your code to GitHub
  2. Import your repository to Vercel
  3. Add your environment variables
  4. Deploy!

Deploy with Vercel

Deploy to Other Platforms

πŸ“š Learning Resources

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ’– Support

If you find this template helpful, please give it a ⭐️ on GitHub and consider:


Made by elhard1

About

πŸš€ Production-ready Next.js 14 + Supabase template with authentication, real-time features, and beautiful UI. Includes TypeScript, Tailwind CSS, and shadcn/ui components.

Topics

Resources

License

Stars

Watchers

Forks