A modern, production-ready React starter template with built-in authentication, backend-as-a-service, and subscription payments.
- ⚡️ Vite + SWC - Lightning fast builds with Vite and SWC
- 🔐 Authentication - Secure authentication with Clerk
- 🗄️ Backend-as-a-Service - Powered by Convex
- 💳 Payments - Subscription payments with Stripe
- 🎨 Styling - Beautiful UI components with Radix UI
- 📱 Responsive - Mobile-first design approach
- 🔍 TypeScript - Type safety and better developer experience
- 🔄 Real-time - Real-time updates with Convex subscriptions
- Frontend Framework: React 18 with TypeScript
- Build Tool: Vite with SWC
- Authentication: Clerk
- Backend: Convex
- Payments: Stripe
- UI Components: Radix UI
- Styling: Tailwind CSS
- Routing: React Router v6
- Type Safety: TypeScript
Before you begin, ensure you have:
- Node.js 18+ installed
- A Clerk account for authentication
- A Convex account for backend services
- A Stripe account for payments
-
Clone the repository
git clone [your-repo-url] cd react-swc-starter -
Install dependencies
npm install
-
Set up environment variables Create a
.envfile in the root directory:# Clerk Authentication VITE_CLERK_PUBLISHABLE_KEY=your_clerk_key # Convex Backend VITE_CONVEX_URL=your_convex_url # Application URLs VITE_FRONTEND_URL=your_frontend_url # Polar.sh Payments (Server-side in Convex) POLAR_ACCESS_TOKEN=your_polar_access_token
For Convex, create a
convex/.envfile:# Polar.sh Configuration POLAR_ACCESS_TOKEN=your_polar_access_token FRONTEND_URL=your_frontend_url
-
Start the development server
npm run dev
react-swc-starter/
├── convex/ # Backend functions and schema
├── public/ # Static assets
├── src/
│ ├── components/ # React components
│ ├── hooks/ # Custom React hooks
│ ├── lib/ # Utility functions
│ ├── types/ # TypeScript types
│ └── App.tsx # Main application component
├── .env # Environment variables
└── package.json # Project dependencies
Authentication is handled by Clerk, providing:
- Email/password authentication
- Social login providers
- User management
- Session handling
Subscription payments are processed through Polar.sh:
- Secure payment processing
- Subscription management
- Usage-based billing
- Customer portal
-
Create a Polar.sh Account
- Sign up at Polar.sh
- Create a new organization
- Get your API access token from the settings
-
Set Up Products
- Create your subscription products in the Polar.sh dashboard
- Note down the product IDs for your plans
- Configure pricing tiers (monthly/yearly)
-
Configure Webhooks
- Set up webhooks in your Polar.sh dashboard
- Add your Convex backend URL as the webhook endpoint
- Ensure the following events are enabled:
- subscription.created
- subscription.activated
- subscription.canceled
- subscription.uncanceled
- subscription.revoked
-
Environment Variables
- Add your Polar.sh access token to both
.envandconvex/.env - Ensure your frontend URL is correctly set for success/cancel redirects
- Add your Polar.sh access token to both
Convex provides:
- Real-time data synchronization
- Automatic caching
- Type-safe database queries
- Serverless functions
- WebSocket connections
The application implements a complete subscription flow:
-
User Authentication
- Users sign in using Clerk authentication
- User data is stored in Convex
-
Subscription Selection
- Users view available plans on the pricing page
- Plans are fetched from Polar.sh
- Monthly and yearly options are available
-
Checkout Process
- Clicking a plan redirects to Polar.sh checkout
- User completes payment on Polar.sh
- Successful payment redirects to success page
- Webhook updates subscription status in Convex
-
Access Control
- Protected routes check subscription status
- Non-subscribed users are redirected to pricing
- Subscribed users can access premium features
-
Subscription Management
- Users can manage their subscription via dashboard
- Cancel/upgrade/downgrade through Polar.sh portal
- Real-time status updates via webhooks
-
Build the project
npm run build
-
Deploy to your preferred platform
- Vercel
- Netlify
- GitHub Pages
- Any static hosting
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request