A comprehensive SaaS boilerplate demonstrating Stripe payment integration with Next.js, featuring one-time payments, subscriptions, and customer billing management.
- β¨ One-Time Payments - Process single transactions seamlessly
- π Subscription Management - Monthly and yearly subscription options
- π° Billing Portal - Self-service customer billing management
- π Secure Authentication - User authentication with Clerk
- π Webhook Integration - Real-time Stripe event handling
- βοΈ Email Notifications - Automated email communication with Resend
- π₯ Production Ready - Deployed and optimized for production
- π Modern Stack - Built with Next.js, TypeScript, and Convex
- Next.js 14
- React
- TypeScript
- Tailwind CSS
- Convex (Backend-as-a-Service)
- Node.js
- Express.js
- Authentication: Clerk
- Payments: Stripe
- Email: Resend
- Caching: Upstash Redis
- Deployment: Vercel
Before you begin, ensure you have:
- Node.js 18+ installed
- A Stripe account
- A Clerk account
- A Convex account
- An Upstash Redis account
- A Resend account
git clone https://github.com/AngeloMafilas/saas_stripe.git
cd saas_stripenpm install
# or
bun installCreate a .env.local file in the root directory:
# Convex
CONVEX_DEPLOYMENT=your_convex_deployment
NEXT_PUBLIC_CONVEX_URL=your_convex_url
# Clerk Authentication
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key
CLERK_SECRET_KEY=your_clerk_secret_key
# Stripe
STRIPE_SECRET_KEY=your_stripe_secret_key
STRIPE_WEBHOOK_SECRET=your_stripe_webhook_secret
STRIPE_MONTHLY_PRICE_ID=your_monthly_price_id
STRIPE_YEARLY_PRICE_ID=your_yearly_price_id
# Upstash Redis
UPSTASH_REDIS_REST_URL=your_upstash_url
UPSTASH_REDIS_REST_TOKEN=your_upstash_token
# Resend Email
RESEND_API_KEY=your_resend_api_key
# App Configuration
NEXT_PUBLIC_APP_URL=http://localhost:3000npm run dev
# or
bun devOpen http://localhost:3000 in your browser.
- Create a Stripe account at stripe.com
- Navigate to Products and create subscription products
- Copy the Price IDs for monthly and yearly plans
- Set up a webhook endpoint pointing to
/api/webhooks/stripe - Copy the webhook signing secret
- Create a Clerk application
- Configure your authentication providers
- Copy the publishable and secret keys
- Initialize Convex in your project:
npx convex dev - Follow the prompts to create a new project
- Copy the deployment URL and key
saas_stripe/
βββ convex/ # Convex backend functions
βββ src/
β βββ app/ # Next.js app router pages
β βββ components/ # React components
β βββ lib/ # Utility functions
βββ public/ # Static assets
βββ courseData.json # Course/product data
βββ sampleData.jsonl # Sample data for testing
βββ screenshot-for-readme.png
The application supports two payment models:
- One-Time Payments: For individual purchases or courses
- Subscriptions: Recurring monthly or yearly billing
Customers can manage their subscriptions through Stripe's hosted billing portal:
- Update payment methods
- View billing history
- Cancel or modify subscriptions
- Download invoices
Stripe webhooks are processed to:
- Update subscription statuses
- Handle payment confirmations
- Manage failed payments
- Trigger email notifications
- Push your code to GitHub
- Import your repository in Vercel
- Configure environment variables
- Deploy
- Update
NEXT_PUBLIC_APP_URLwith your production URL - Update Stripe webhook endpoint to production URL
- Test all payment flows in production mode
The application uses Resend to send:
- Payment confirmations
- Subscription updates
- Receipt emails
- Welcome emails
- All sensitive keys are stored in environment variables
- Stripe webhook signatures are verified
- Authentication is handled by Clerk
- API routes are protected
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source and available under the MIT License.
- Built as a learning resource for Stripe integration
- Inspired by modern SaaS applications
- Community feedback and contributions
For questions or issues:
- Open an issue on GitHub
- Check the Stripe documentation
- Review the Next.js documentation
Note: This is a learning project. For production use, ensure thorough testing and security audits.
