Deploying to Vercel
Vercel is an excellent platform for deploying Next.js applications. This guide will walk you through the process of deploying your Supabase TDD Boilerplate project to Vercel.
Prerequisites
- A Vercel account.
- Your project pushed to a Git repository (Ideally Github).
Steps to Deploy
1. Connect Your Repository
- Log in to your Vercel account.
- Click "Add New..." and select "Project".
- Choose your Git provider and select your repository.
2. Configure Your Project
-
Set the directory to
apps/web - Set your Environment Variables:
- Click on "Environment Variables".
- Add all the necessary variables from your
apps/web/.env.localfile. - Ensure you're using production values for services like Stripe and Supabase.
3. Deploy
- Click "Deploy".
- Vercel will build and deploy your application.
Setting Up a Custom Domain
- In your project dashboard, go to "Settings" > "Domains".
- Add your custom domain and follow the instructions to configure your DNS settings.
Configuring Continuous Deployment
Vercel automatically sets up continuous deployment. Every push to your main branch will trigger a new deployment.
To change this behavior:
- Go to "Settings" > "Git".
- Under "Production Branch", you can change which branch deploys to production.
Environment Variables
Ensure you've set all necessary environment variables in Vercel:
NEXT_PUBLIC_SUPABASE_URLNEXT_PUBLIC_SUPABASE_ANON_KEYSUPABASE_SERVICE_ROLE_KEYNEXT_PUBLIC_SITE_URLRESEND_API_KEYGOOGLE_CLIENT_IDGOOGLE_CLIENT_SECRETNEXT_PUBLIC_STRIPE_PUBLIC_KEYSTRIPE_SECRET_KEYSTRIPE_WEBHOOK_SECRETNEXT_PUBLIC_STRIPE_PRICE_ID_SINGLE_PAYMENTNEXT_PUBLIC_STRIPE_PRICE_ID_SINGLE_PAYMENT_SECONDARYNEXT_PUBLIC_STRIPE_PRICE_ID_MONTHLY_SUBSCRIPTIONSENTRY_AUTH_TOKENNEXT_PUBLIC_SENTRY_DSNNEXT_PUBLIC_SENTRY_ORGNEXT_PUBLIC_SENTRY_PROJECT
Best Practices
- Use Vercel's Preview Deployments feature to test changes before merging to production.
- Set up separate projects for staging and production environments.
- Regularly review and update your environment variables.
Troubleshooting
- If your build fails, check the build logs for errors.
- Ensure all dependencies are correctly listed in your
package.json. - Verify that your environment variables are correctly set in Vercel.
By following these steps, you'll have your application deployed and running on Vercel, ready for users to access!