A modern, feature-rich starter template for building production-ready applications with Next.js 15, Tailwind CSS, and TypeScript.
- ⚡ Next.js 15 - The latest version with App Router
- 🎨 Tailwind CSS - Utility-first CSS framework
- 📘 TypeScript - Type-safe code
- 🔒 Authentication - Clerk integration with persistent authorization toggle
- 🎭 Shadcn/ui - Beautiful and accessible components
- 💾 Convex DB - Real-time database with built-in file storage and serverless functions
- 💳 Polar.sh - Open-source solution for managing subscriptions and payments
- 🚀 Route Prefetching - Instant page transitions for dashboard, playground, and auth pages
- 🖼️ Optimized Images - Eager loading for critical images
- 🌓 Dark/Light Mode - System-aware theme switching with custom gradients
- 📱 Responsive Design - Mobile-first approach
- 🔄 Real-time Updates - Powered by Convex DB's real-time capabilities
- 🧩 Component Library - Pre-built, customizable components
- 🎮 AI Playground - Built-in AI chat interface
- 📊 Dashboard Template - Ready-to-use admin interface with subscription management
- 🔍 SEO Optimized - Meta tags and sitemap generation
To set up your Convex database, visit: https://convex.link/rasmicstarter
For detailed setup instructions, please refer to the complete setup guide and video tutorial sections below.
- Clone the repository:
git clone https://github.com/michaelshimeles/nextjs-starter-kit.git
- Install dependencies:
bun install
- Set up environment variables:
cp .env.example .env.local
- Configure your environment variables:
# Authentication (Clerk)
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=
CLERK_SECRET_KEY=
NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in
NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up
NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/
# Convex
NEXT_PUBLIC_CONVEX_URL=
CONVEX_DEPLOYMENT=
CONVEX_ADMIN_KEY=
# Polar.sh
POLAR_WEBHOOK_SECRET=
# Frontend
NEXT_PUBLIC_BASE_URL=http://localhost:3000
# Optional: AI Integration
OPENAI_API_KEY=
- Run the development server:
bun run dev
Open http://localhost:3000 to see your application.
├── app/
│ ├── (auth)/ # Authentication routes
│ ├── (marketing)/ # Marketing pages
│ ├── api/ # API routes
│ ├── dashboard/ # Dashboard pages
│ └── playground/ # AI Playground
├── components/
│ ├── homepage/ # Landing page components
│ ├── shared/ # Shared UI components
│ └── wrapper/ # Layout wrappers and navigation
├── config/ # Configuration files
├── convex/ # Convex DB schema and functions
├── lib/ # Utility functions
├── public/ # Static assets
│ ├── images/ # Image assets
│ └── svg/ # SVG assets
└── styles/ # Global styles
bun run dev
- Start development serverbun run build
- Build for productionbun run start
- Start production serverbun run lint
- Run ESLintbun run format
- Format code with Prettier
Watch this video for a complete walkthrough of setting up the starter kit:
The video covers:
- Complete setup process from start to finish
- Authentication setup with Clerk
- Database setup with Convex
- Payment integration with Polar.sh
- Local development with ngrok
- Testing the subscription flow
- Troubleshooting common issues
- Clone the repository:
git clone https://github.com/michaelshimeles/nextjs-starter-kit.git
- Install dependencies:
bun install
- Create environment variables file:
cp .env.example .env.local
- Go to clerk.com and create a new project
- Name your project (e.g., "next-starter")
- Select authentication methods (Email and Google recommended)
- Copy these environment variables to
.env.local
:
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=
CLERK_SECRET_KEY=
NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in
NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up
NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/
- Go to JWT Templates in Clerk dashboard
- Create a new template selecting Convex
- Copy the issuer URL for the next step
- Important: Click Save on the JWT template
- Run the following command to create a new Convex project:
npx convex dev
- When prompted, create a new project and name it in the Convex dashboard
- The command will automatically add the
NEXT_PUBLIC_CONVEX_URL
to your.env.local
- Add these environment variables in the Convex dashboard:
CLERK_SIGNING_KEY
(from Clerk JWT issuer URL)FRONTEND_URL
(your app URL, will be set in Local Development)POLAR_ACCESS_TOKEN
(will get this in next step)POLAR_WEBHOOK_SECRET
(will get this in Polar setup)
- Go to sandbox.polar.sh for testing (use this instead of production polar.sh)
- Create a new organization
- Create a new product:
- Set name and description
- Add monthly pricing (e.g., $12/month)
- Add yearly pricing (e.g., $100/year)
- Copy the product ID and price IDs (click the three dots next to the product)
- Generate an access token:
- Go to Settings
- Create new access token with full permissions
- Set no expiration date for testing
- Add the token to Convex environment variables as
POLAR_ACCESS_TOKEN
- Set up webhook:
- Go to Settings > Webhooks
- Add endpoint: Your Convex HTTP Actions URL +
/payment-webhook
- Find your Convex HTTP Actions URL in the Convex dashboard under "Settings > URL & Deploy Key"
- It looks like:
https://<your-deployment-id>.convex.site
- The final webhook URL should be:
https://<your-deployment-id>.convex.site/payment-webhook
- Select "Raw" format
- Select all event types
- Click "Generate" to create a webhook secret
- Copy the webhook secret
- Add it to Convex environment variables as
POLAR_WEBHOOK_SECRET
- Click "Create" to save the webhook
When you run npx convex dev
, these tables will be automatically created:
users
: Stores user informationsubscriptions
: Stores subscription detailsplans
: Stores your product planswebhookEvents
: Tracks webhook events from Polar
In your Convex dashboard, add a plan to the plans
table:
{
"description": "<your-description>",
"key": "pro",
"name": "<your-plan-name>",
"polarProductId": "<your-product-id>",
"prices": {
"month": {
"usd": {
"amount": "<monthly-amount>",
"polarId": "<monthly-price-id>"
}
},
"year": {
"usd": {
"amount": "<yearly-amount>",
"polarId": "<yearly-price-id>"
}
}
}
}
- Install ngrok for local webhook testing
- Start the development server:
bun run dev
- In a new terminal, run ngrok:
ngrok http 3000
- Copy the ngrok URL (e.g.,
https://xxxx-xx-xx-xxx-xx.ngrok.io
) - Set this URL as
FRONTEND_URL
in your Convex environment variables
When deploying to production:
- Replace the
FRONTEND_URL
in Convex environment variables with your production URL - Update the webhook URL in Polar.sh dashboard to use your production Convex URL
- Consider creating a new organization in production Polar.sh instead of sandbox
Add these environment variables to .env.local
to enable the AI chat feature:
OPENAI_API_KEY=your_key
DEEPSEEK_API_KEY=your_key
GROQ_API_KEY=your_key
- Start the development server and visit http://localhost:3000
- Try signing up and accessing the dashboard
- Test the subscription flow with these test card details:
- Card number:
4242 4242 4242 4242
- Any future expiry date
- Any 3 digits for CVC
- Any name and address
- Card number:
- After subscribing:
- Check the Convex dashboard's Data section
- Verify that the
subscriptions
table has been updated - Check the
webhookEvents
table for successful webhook delivery
- Test subscription cancellation:
- Go to dashboard settings
- Cancel your subscription
- Verify that you lose access to protected routes
- Check that the subscription status is updated in Convex
- If subscription isn't working:
- Verify webhook is properly configured in Polar
- Check Convex webhook secret is correct
- Ensure plan IDs match in Polar and Convex plans table
- Check the
webhookEvents
table in Convex for any errors - Verify the
FRONTEND_URL
matches your current environment
- If authentication isn't working:
- Verify Clerk JWT template is saved
- Check Clerk signing key in Convex
- Ensure all Clerk environment variables are set correctly
- If AI playground isn't responding:
- Verify API keys are correctly set in environment variables
- Check for any console errors in the browser
Special thanks to Convex for their sponsorship and support in making this starter kit possible. Their real-time database and file storage solutions have been instrumental in creating a powerful foundation for modern web applications.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - 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!