Deployment
NextShip is optimized for deployment on Vercel, but works with any Node.js hosting.
Vercel Deployment
1. Connect Repository
- Go to vercel.com
- Click "Add New Project"
- Import your GitHub repository
- Select the Next.js framework preset
2. Configure Environment Variables
Add all required environment variables in Vercel project settings:
# Required
NEXT_PUBLIC_APP_URL=https://yourdomain.com
DATABASE_URL=postgresql://...
BETTER_AUTH_SECRET=your-secret
# Stripe
STRIPE_SECRET_KEY=sk_live_xxx
STRIPE_WEBHOOK_SECRET=whsec_xxx
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_live_xxx
# Resend
RESEND_API_KEY=re_xxx
# OAuth (if using)
GOOGLE_CLIENT_ID=xxx
GOOGLE_CLIENT_SECRET=xxx
GITHUB_CLIENT_ID=xxx
GITHUB_CLIENT_SECRET=xxx3. Deploy
Click "Deploy" and Vercel will:
- Install dependencies
- Build the project
- Deploy to production
4. Configure Domain
- Go to project settings → Domains
- Add your custom domain
- Update DNS records as instructed
Stripe Webhook Setup
For production, configure Stripe webhooks:
- Go to Stripe Dashboard → Developers → Webhooks
- Add endpoint:
https://yourdomain.com/api/stripe/webhook - Select events:
checkout.session.completedcustomer.subscription.updatedcustomer.subscription.deletedinvoice.payment_failed
- Copy the signing secret to
STRIPE_WEBHOOK_SECRET
Database Setup
Neon (Recommended)
- Create account at neon.tech
- Create a new project
- Copy the connection string to
DATABASE_URL - Run migrations:
pnpm db:push
Other PostgreSQL Providers
- Supabase
- Railway
- PlanetScale (MySQL mode)
- AWS RDS
Deployment Checklist
Before going live:
- All environment variables configured
- Database migrated
- Stripe webhook endpoint configured
- Email domain verified in Resend
- OAuth apps configured for production URLs
- Error monitoring set up (Sentry)
- Analytics configured (PostHog)
- Custom domain configured
- SSL certificate active
Performance Optimization
Edge Functions
Next.js automatically uses edge functions for:
- Middleware
- API routes (when configured)
Image Optimization
Configure allowed domains in next.config.ts:
images: {
remotePatterns: [
{ hostname: "yourdomain.com" },
{ hostname: "avatars.githubusercontent.com" },
],
}Caching
- Static pages are cached at the edge
- API responses can be cached with
Cache-Controlheaders - Use Upstash Redis for application-level caching
Monitoring
Sentry (Error Tracking)
// sentry.client.config.ts
Sentry.init({
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
tracesSampleRate: 1.0,
});PostHog (Analytics)
// providers.tsx
<PostHogProvider apiKey={process.env.NEXT_PUBLIC_POSTHOG_KEY}>
{children}
</PostHogProvider>Cost Estimation
| Service | Free Tier | Estimated Cost at Scale |
|---|---|---|
| Vercel | 100GB bandwidth | $20/month |
| Neon | 0.5GB storage | $19/month |
| Stripe | No monthly fee | 2.9% + $0.30/transaction |
| Resend | 3,000 emails/month | $20/month |
| Sentry | 5,000 errors/month | $26/month |