- ποΈ 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
# 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- Create a Supabase project at supabase.com
- Copy your project credentials
- Set up environment variables:
cp .env.example .env.local- Fill in your Supabase credentials in
.env.local
npm run devVisit http://localhost:3000 π
// 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'
})// 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)// Subscribe to changes
const subscription = supabase
.channel('todos')
.on('postgres_changes',
{ event: '*', schema: 'public', table: 'todos' },
(payload) => {
console.log('Change received!', payload)
}
)
.subscribe()// 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')βββ 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
-- 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);- Create a new bucket:
insert into storage.buckets (id, name)
values ('avatars', 'avatars');- 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 );- Push your code to GitHub
- Import your repository to Vercel
- Add your environment variables
- Deploy!
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
If you find this template helpful, please give it a βοΈ on GitHub and consider:
Made by elhard1
