Skip to main content

Overview

Sistema Financiero is a Next.js application that can be deployed to any platform supporting Node.js 20+. This guide covers the most popular deployment platforms.
All deployment methods require a configured Supabase project. Complete Supabase Configuration first.

Deployment Platforms Comparison

PlatformFree TierBuild TimeEdge NetworkBest For
Vercel✅ Hobby (generous)~2 min✅ Global CDNNext.js apps (recommended)
Railway❌ $5/month~3 min✅ GlobalFull-stack with DB
Netlify✅ Starter~2 min✅ Global CDNStatic + serverless
Render✅ Free tier~5 min❌ Single regionSimple deployments
Cloudflare Pages✅ Free (unlimited)~2 min✅ 300+ locationsEdge-first apps
Self-Hosted✅ (your server)~2 minFull control
Recommended: Vercel is built by the creators of Next.js and offers the best developer experience with zero configuration.

Prerequisites

  • GitHub, GitLab, or Bitbucket account
  • Code pushed to a repository
  • Supabase project configured

Deployment Steps

1

Push Code to GitHub

If you haven’t already:
Terminal
git init
git add .
git commit -m "Initial commit"
git remote add origin https://github.com/yourusername/sistema-financiero.git
git push -u origin main
2

Import Project to Vercel

  1. Go to vercel.com and sign in with GitHub
  2. Click Add NewProject
  3. Select your sistema-financiero repository
  4. Click Import
Vercel auto-detects Next.js and configures build settings.
3

Configure Environment Variables

Before deploying, add environment variables:
  1. In the Configure Project screen, expand Environment Variables
  2. Add each variable:
KeyValueEnvironment
NEXT_PUBLIC_SUPABASE_URLYour Supabase URLProduction, Preview, Development
NEXT_PUBLIC_SUPABASE_ANON_KEYYour Supabase anon keyProduction, Preview, Development
OPENROUTER_API_KEYYour OpenRouter key (optional)Production, Preview, Development
NEXT_PUBLIC_APP_URLhttps://your-app.vercel.appProduction
For NEXT_PUBLIC_APP_URL, use a placeholder first (like https://sistema-financiero.vercel.app), then update it after deployment with your actual Vercel URL.
4

Deploy

Click Deploy and wait ~2 minutes.You’ll see build logs streaming. Once complete, you’ll get a deployment URL like:
https://sistema-financiero-abc123.vercel.app
5

Update App URL

After first deployment:
  1. Go to SettingsEnvironment Variables
  2. Find NEXT_PUBLIC_APP_URL
  3. Update to your actual Vercel URL
  4. Redeploy:
    Terminal
    git commit --allow-empty -m "Update app URL"
    git push
    

Custom Domain (Optional)

1

Add Domain in Vercel

  1. Go to your project SettingsDomains
  2. Enter your domain (e.g., finanzas.tuempresa.com)
  3. Click Add
2

Configure DNS

Vercel will show DNS records to add:For root domains (example.com):
A Record:
Name: @
Value: 76.76.21.21
For subdomains (app.example.com):
CNAME Record:
Name: app
Value: cname.vercel-dns.com
Add these records in your domain registrar (GoDaddy, Namecheap, Cloudflare, etc.)
3

Wait for Verification

DNS propagation takes 5-60 minutes. Vercel will automatically issue an SSL certificate once verified.

Continuous Deployment

Vercel automatically deploys on every git push:
  • Production: Commits to main branch → your-app.vercel.app
  • Preview: Commits to other branches → your-app-git-branch.vercel.app
  • Pull Requests: Each PR gets a unique preview URL
Preview deployments let you test changes before merging to production. Share the URL with team members for review.

Deploy to Railway

Deployment Steps

1

Create Railway Account

  1. Go to railway.app
  2. Sign up with GitHub
  3. Verify your email
2

Create New Project

  1. Click New Project
  2. Select Deploy from GitHub repo
  3. Choose your sistema-financiero repository
  4. Click Deploy Now
3

Add Environment Variables

  1. Click on your service
  2. Go to Variables tab
  3. Click New Variable for each:
    NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
    NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGc...
    OPENROUTER_API_KEY=sk-or-v1-...
    NEXT_PUBLIC_APP_URL=https://your-app.up.railway.app
    
4

Configure Build Settings

Railway auto-detects Next.js. If needed, manually set:
  • Build Command: npm run build
  • Start Command: npm run start
  • Port: 3000 (auto-detected)
5

Deploy

Railway automatically deploys. Check the Deployments tab for progress.Once complete, click View Deployment to see your live app.

Custom Domain on Railway

  1. Go to SettingsNetworking
  2. Click Custom Domain
  3. Enter your domain and follow DNS instructions
  4. Add the provided CNAME record to your DNS
Railway provides automatic SSL certificates for custom domains.

Deploy to Netlify

Deployment Steps

1

Create Netlify Account

  1. Go to netlify.com
  2. Sign up with GitHub
2

Import Project

  1. Click Add new siteImport an existing project
  2. Select GitHub
  3. Authorize Netlify
  4. Choose your repository
3

Configure Build Settings

Netlify should auto-detect these settings:
  • Build command: npm run build
  • Publish directory: .next
  • Functions directory: .netlify/functions (auto-created)
Netlify requires the Next.js Runtime plugin. It’s usually auto-installed, but if builds fail, add it manually in Site SettingsBuild & deployBuild plugins.
4

Add Environment Variables

  1. Go to Site settingsBuild & deployEnvironment
  2. Click Edit variables
  3. Add each variable:
    NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
    NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGc...
    OPENROUTER_API_KEY=sk-or-v1-...
    NEXT_PUBLIC_APP_URL=https://your-app.netlify.app
    
5

Deploy

Click Deploy site. Initial build takes ~3 minutes.Once complete, you’ll get a URL like https://sistema-financiero.netlify.app.

Deploy to Render

1

Create Render Account

Sign up at render.com with GitHub.
2

Create Web Service

  1. Click NewWeb Service
  2. Connect your GitHub repository
  3. Configure:
    • Name: sistema-financiero
    • Environment: Node
    • Build Command: npm install && npm run build
    • Start Command: npm run start
3

Add Environment Variables

In the Environment section, add:
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGc...
OPENROUTER_API_KEY=sk-or-v1-...
NEXT_PUBLIC_APP_URL=https://sistema-financiero.onrender.com
4

Deploy

Click Create Web Service. First deployment takes ~5 minutes.
Render’s free tier may spin down after inactivity. First request after idle takes 30-60 seconds to wake up.

Deploy to Cloudflare Pages

1

Install Wrangler CLI

Terminal
npm install -g wrangler
wrangler login
2

Configure for Cloudflare Pages

Cloudflare Pages requires adapter configuration. Add to package.json:
package.json
{
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "pages:build": "npx @cloudflare/next-on-pages",
    "pages:dev": "npx @cloudflare/next-on-pages --watch"
  }
}
Install adapter:
Terminal
npm install --save-dev @cloudflare/next-on-pages
3

Deploy

Terminal
npm run pages:build
npx wrangler pages deploy .vercel/output/static
4

Add Environment Variables

In Cloudflare dashboard:
  1. Go to Workers & Pages → Your project
  2. SettingsEnvironment Variables
  3. Add each variable for Production and Preview
Cloudflare Pages has limitations with Next.js API routes. Some features (like streaming AI responses) may not work. Vercel or Railway are better choices for full functionality.

Self-Hosted Deployment

Using Docker

1

Create Dockerfile

Create Dockerfile in project root:
Dockerfile
FROM node:20-alpine AS base

# Install dependencies
FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app

COPY package*.json ./
RUN npm ci

# Build application
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

# Set build-time env vars
ARG NEXT_PUBLIC_SUPABASE_URL
ARG NEXT_PUBLIC_SUPABASE_ANON_KEY
ARG NEXT_PUBLIC_APP_URL
ENV NEXT_PUBLIC_SUPABASE_URL=$NEXT_PUBLIC_SUPABASE_URL
ENV NEXT_PUBLIC_SUPABASE_ANON_KEY=$NEXT_PUBLIC_SUPABASE_ANON_KEY
ENV NEXT_PUBLIC_APP_URL=$NEXT_PUBLIC_APP_URL

RUN npm run build

# Production image
FROM base AS runner
WORKDIR /app

ENV NODE_ENV=production

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

EXPOSE 3000

ENV PORT=3000
ENV HOSTNAME="0.0.0.0"

CMD ["node", "server.js"]
2

Update next.config.ts

Enable standalone output:
next.config.ts
import type { NextConfig } from 'next'

const nextConfig: NextConfig = {
  output: 'standalone',
}

export default nextConfig
3

Build Image

Terminal
docker build \
  --build-arg NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co \
  --build-arg NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGc... \
  --build-arg NEXT_PUBLIC_APP_URL=https://your-domain.com \
  -t sistema-financiero .
4

Run Container

Terminal
docker run -d \
  -p 3000:3000 \
  -e OPENROUTER_API_KEY=sk-or-v1-... \
  --name sistema-financiero \
  sistema-financiero
Access at http://localhost:3000

Using PM2 (Node.js Process Manager)

1

Install PM2

Terminal
npm install -g pm2
2

Build Application

Terminal
npm run build
3

Create PM2 Config

Create ecosystem.config.js:
ecosystem.config.js
module.exports = {
  apps: [{
    name: 'sistema-financiero',
    script: 'node_modules/next/dist/bin/next',
    args: 'start',
    env: {
      NODE_ENV: 'production',
      PORT: 3000,
      NEXT_PUBLIC_SUPABASE_URL: 'https://your-project.supabase.co',
      NEXT_PUBLIC_SUPABASE_ANON_KEY: 'eyJhbGc...',
      OPENROUTER_API_KEY: 'sk-or-v1-...',
      NEXT_PUBLIC_APP_URL: 'https://your-domain.com',
    },
    instances: 'max',
    exec_mode: 'cluster',
    watch: false,
    max_memory_restart: '500M',
  }]
}
4

Start with PM2

Terminal
pm2 start ecosystem.config.js
pm2 save
pm2 startup
PM2 will auto-restart your app on crashes and reboot.

Nginx Reverse Proxy

If running on a VPS, use Nginx as a reverse proxy:
/etc/nginx/sites-available/sistema-financiero
server {
    listen 80;
    server_name finanzas.tuempresa.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;
    }
}
Enable SSL with Let’s Encrypt:
Terminal
sudo certbot --nginx -d finanzas.tuempresa.com

Post-Deployment Checklist

1

Verify Application Loads

Visit your deployment URL and check:
  • ✅ Dashboard loads without errors
  • ✅ No console errors in browser DevTools (F12)
  • ✅ Favicon and images load
2

Test Database Connection

  1. Try adding a transaction via the manual form
  2. Check if it appears in the dashboard
  3. Verify data is saved in Supabase Table Editor
3

Test AI Features (if enabled)

  1. Go to the AI chat page (/agente-mejorado)
  2. Send a test message: “Gasté $100 en gasolina”
  3. Verify the transaction is registered
4

Check Performance

Run PageSpeed Insights:
https://pagespeed.web.dev/analysis?url=https://your-app.vercel.app
Target scores:
  • Performance: 90+
  • Accessibility: 95+
  • Best Practices: 95+
  • SEO: 90+
5

Set Up Monitoring (Optional)

Add error tracking with Sentry:
Terminal
npm install @sentry/nextjs
npx @sentry/wizard@latest -i nextjs
Or use Vercel Analytics (free for Vercel deployments):
Terminal
npm install @vercel/analytics
app/layout.tsx
import { Analytics } from '@vercel/analytics/react'

export default function RootLayout({ children }) {
  return (
    <html>
      <body>
        {children}
        <Analytics />
      </body>
    </html>
  )
}

Troubleshooting Deployment Issues

Problem: Missing dependencies or incorrect imports.Solution:
# Clear cache and reinstall
rm -rf node_modules .next package-lock.json
npm install
npm run build
Check import paths are correct:
// ✅ Correct (using tsconfig path alias)
import { supabase } from '@/lib/supabase'

// ❌ Wrong (relative path may break)
import { supabase } from '../../../lib/supabase'
Problem: Missing environment variables or runtime errors.Solution:
  1. Check deployment logs for error messages
  2. Verify all required env vars are set in platform UI
  3. Ensure NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY are present
  4. Test locally with production env:
    NODE_ENV=production npm run build && npm run start
    
Problem: Server-side errors in API routes.Solution:
  1. Check server logs (Vercel: Deployment logs, Railway: Service logs)
  2. Common issues:
    • Missing OPENROUTER_API_KEY (if using AI features)
    • Supabase connection fails (check URL/key)
    • CORS issues (check API route headers)
  3. Add error logging:
    export async function POST(request: Request) {
      try {
        // Your code
      } catch (error) {
        console.error('API Error:', error)
        return NextResponse.json(
          { error: String(error) },
          { status: 500 }
        )
      }
    }
    
Problem: First request after idle takes 10+ seconds.Solution:
  • Vercel: Upgrade to Pro plan for always-warm instances
  • Railway: No cold starts (paid plans keep services running)
  • Render: Free tier spins down after 15min idle (upgrade to keep alive)
  • Self-hosted: No cold starts
Problem: Dashboard takes 5+ seconds to load.Solution:
  1. Check Supabase region matches deployment region
  2. Verify indexes exist (see Supabase Configuration)
  3. Add query optimization:
    // ❌ Slow (fetches all fields)
    const { data } = await supabase.from('transacciones').select('*')
    
    // ✅ Fast (only needed fields)
    const { data } = await supabase
      .from('transacciones')
      .select('fecha, tipo, monto, categoria')
      .order('fecha', { ascending: false })
      .limit(100)
    

Rollback Deployment

Vercel

  1. Go to Deployments tab
  2. Find previous working deployment
  3. Click Promote to Production

Railway

  1. Go to Deployments tab
  2. Find previous deployment
  3. Click Redeploy

Git-Based Rollback

For any platform:
Terminal
# Revert last commit
git revert HEAD
git push

# Or rollback to specific commit
git reset --hard <commit-hash>
git push --force
Use --force carefully! It rewrites Git history and can affect team members.

Next Steps

Dashboard Features

Learn how to use the dashboard

API Reference

Integrate with the API

Customization

Customize the UI and features

Troubleshooting

Fix common problems
Congratulations! Your Sistema Financiero instance is now live. 🎉

Build docs developers (and LLMs) love