This guide provides detailed instructions for deploying your NextReady application to various hosting platforms. Follow these steps to get your application up and running in a production environment.
NextReady can be deployed to several platforms, each with its own advantages:
Vercel is the recommended platform for deploying Next.js applications, offering the best integration and performance.
Log in to your Vercel account and click "New Project"
Import your repository from GitHub, GitLab, or Bitbucket
Configure your project settings:
./
(or your project root)next build
.next
Add your environment variables:
# Required environment variables
MONGODB_URI=mongodb+srv://user:password@cluster.mongodb.net/production-db
NEXTAUTH_URL=https://your-domain.com
NEXTAUTH_SECRET=your-nextauth-secret
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
STRIPE_SECRET_KEY=sk_live_...
STRIPE_WEBHOOK_SECRET=whsec_...
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_live_...
EMAIL_SERVER_HOST=smtp.example.com
EMAIL_SERVER_PORT=587
EMAIL_SERVER_USER=your-email@example.com
EMAIL_SERVER_PASSWORD=your-email-password
EMAIL_FROM=noreply@your-domain.com
Click "Deploy" and wait for the build to complete
Once deployed, you can access your application at the provided Vercel URL
In your Vercel project dashboard, go to "Settings" > "Domains"
Add your custom domain and follow the instructions to configure DNS settings
Vercel will automatically provision an SSL certificate for your domain
For Stripe webhooks, use the following URL format:
https://your-domain.com/api/webhooks/stripe
Log in to your Netlify account and click "New site from Git"
Connect to your Git provider and select your repository
Configure build settings:
next build
.next
Add your environment variables in the "Advanced build settings" section
Click "Deploy site" and wait for the build to complete
Create a netlify.toml
file in your project root:
[build]
command = "next build"
publish = ".next"
[build.environment]
NEXT_USE_NETLIFY_EDGE = "true"
[[plugins]]
package = "@netlify/plugin-nextjs"
[[redirects]]
from = "/*"
to = "/_ipx:path*"
status = 200
force = true
conditions = {Path = ["/_ipx/**"]}
[[redirects]]
from = "/*"
to = "/404"
status = 404
Log in to the AWS Management Console and navigate to AWS Amplify
Click "New app" > "Host web app"
Connect to your Git provider and select your repository
Configure build settings:
version: 1
frontend:
phases:
preBuild:
commands:
- npm ci
build:
commands:
- npm run build
artifacts:
baseDirectory: .next
files:
- '**/*'
cache:
paths:
- node_modules/**/*
Add your environment variables in the "Environment variables" section
Click "Save and deploy" and wait for the build to complete
Log in to your Railway account and click "New Project"
Select "Deploy from GitHub repo"
Connect to your GitHub account and select your repository
Configure your project settings:
./
(or your project root)npm run build
npm start
Add your environment variables in the "Variables" tab
Railway will automatically deploy your application
Log in to your DigitalOcean account and navigate to the App Platform
Click "Create App" and connect to your Git provider
Select your repository and branch
Configure your app settings:
npm run build
npm start
Add your environment variables in the "Environment Variables" section
Select your plan and click "Launch App"
Clone your repository to the server:
git clone https://github.com/yourusername/your-repo.git
cd your-repo
Install dependencies and build the application:
npm ci
npm run build
Create a .env.local file with your environment variables
Install PM2 and start your application:
npm install -g pm2
pm2 start npm --name "nextready" -- start
Configure Nginx as a reverse proxy:
server {
listen 80;
server_name your-domain.com;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Set up SSL with Certbot:
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d your-domain.com
For production, we recommend using MongoDB Atlas:
Create a MongoDB Atlas account at mongodb.com/cloud/atlas
Create a new cluster (the free tier is sufficient for starting out)
Set up a database user with appropriate permissions
Configure network access (IP whitelist) or allow access from anywhere for testing
Get your connection string and update your environment variables
After deployment, update your Stripe webhook endpoint:
Go to the Stripe Dashboard > Developers > Webhooks
Add an endpoint with your production URL:
https://your-domain.com/api/webhooks/stripe
Select the following events to listen for:
checkout.session.completed
customer.subscription.created
customer.subscription.updated
customer.subscription.deleted
invoice.payment_succeeded
invoice.payment_failed
Get the webhook signing secret and update your environment variable
Update your Google OAuth credentials:
Go to the Google Cloud Console > APIs & Services > Credentials
Edit your OAuth 2.0 Client ID
Add your production domain to the Authorized JavaScript origins:
https://your-domain.com
Add your production redirect URI:
https://your-domain.com/api/auth/callback/google
Set up uptime monitoring with a service like UptimeRobot or Pingdom to be alerted if your site goes down.
Implement error tracking with Sentry or a similar service:
// Install Sentry
npm install @sentry/nextjs
// Configure Sentry
// sentry.client.config.js
import * as Sentry from '@sentry/nextjs';
Sentry.init({
dsn: 'your-sentry-dsn',
tracesSampleRate: 0.5,
});
// sentry.server.config.js
import * as Sentry from '@sentry/nextjs';
Sentry.init({
dsn: 'your-sentry-dsn',
tracesSampleRate: 0.5,
});
Ensure your MongoDB database is regularly backed up. MongoDB Atlas provides automated backups.
Set up continuous deployment to automatically deploy changes when you push to your main branch.
Build Failures: Check your build logs for errors. Common issues include missing dependencies or environment variables.
API Routes Not Working: Ensure your API routes are properly configured and environment variables are set correctly.
Database Connection Issues: Verify your MongoDB connection string and network access settings.
Authentication Problems: Check your NextAuth.js configuration and OAuth provider settings.
Stripe Webhook Errors: Ensure your webhook endpoint is correctly configured and the signing secret is set.
Always check your deployment logs for errors:
After successfully deploying your application, consider these next steps: