Published on
Where should you host a Next.js app with a database in Brazil?
For a Next.js app with PostgreSQL and users in Brazil, the two practical options are Vercel with functions in São Paulo (gru1) plus a Neon database in the same region, or Next.js running as a continuous server (next start or output: "standalone") on a platform with a managed database in Brazil, such as Zenifra. In the three sizes calculated below, Vercel with Neon came to between R$ 171.70 and R$ 874.99 a month on a card (PTAX rate of 11/05/2026 plus 3.5% IOF), and the equivalent setup on Zenifra to between R$ 42.20 and R$ 379.70 in reais, with the caveat that Vercel is still the better fit if you rely on its global CDN and its own platform features.
How Vercel runs a Next.js app with a database
On Vercel, the server code of a Next.js app (dynamic pages, API routes, Server Actions) runs in Vercel Functions. Each function starts an instance when the first request arrives, serves several requests at once in the model Vercel calls fluid compute, and is paused when the last request finishes. Billing follows that cycle: provisioned memory per GB-hour while the instance is alive, active CPU per hour only while code is executing (waiting for a database query does not count as CPU), and US$ 0.60 per million invocations. A function defaults to 2 GB of memory with 1 vCPU, and on Pro you can go up to 4 GB with 2 vCPUs.
The price depends on the region. In São Paulo (gru1), Vercel charges US$ 0.221 per hour of active CPU and US$ 0.0183 per GB-hour of memory, the highest values in the regional table published on June 16, 2026. Washington (iad1), the default region for every new project, charges US$ 0.128 and US$ 0.0106. In other words, if you want functions close to Brazilian users, you pay more for it and you have to change the region manually in the project settings or in vercel.json.
The database does not live on Vercel. Vercel Postgres no longer exists: existing databases were moved to Neon in December 2024, and new projects install PostgreSQL from the Marketplace (Neon, Supabase, Prisma Postgres, AWS Aurora and others). On Neon, the Launch plan charges US$ 0.106 per compute CU-hour and US$ 0.35 per GB-month of storage, and each CU is about 4 GB of RAM. Neon has the aws-sa-east-1 region in São Paulo, the same AWS region Vercel uses for gru1.
The Pro plan costs US$ 20 a month with US$ 20 of usage credit, includes one developer seat and charges US$ 20 a month for each additional seat that deploys. This design works well for irregular traffic, because nothing is billed between requests. Cost grows when the app is busy all day, since the memory of each live instance is billed for the whole time.
Next.js as a continuous server, next to the database
The other way to deploy Next.js is the one the framework’s own documentation lists first: run npm run build and then npm run start, which starts a Node.js server. According to the official documentation, this server supports every Next.js feature, and the same is true for deploying in a Docker container. The output: "standalone" option in next.config produces a .next/standalone folder with only the required files and a minimal server.js that runs without installing node_modules again.
On a platform such as Zenifra, that server stays on all the time in an instance whose CPU and memory come from the plan. The process is not paused between requests, so there is no per-request cold start, and the app keeps a connection pool open to the database instead of opening new connections on every call. Zenifra’s documentation describes the difference like this: on Vercel, server code runs in functions that start on demand and scale to zero; on Zenifra, the app is a continuous server that reuses database connections.
The nature of the price changes too. Instead of GB-hours and active CPU, you pay for the instance plan: hourly, monthly or yearly, in reais. Basic has 0.5 vCPU and 512 MB for R$ 29.90 a month, Premium has 1 vCPU and 1 GB for R$ 62.90, and Premium Plus has 2 vCPUs and 2 GB for R$ 119.90. Managed PostgreSQL is separate, from R$ 11.90 a month on DB-Starter, with disk billed per GB. An idle instance with no traffic costs the same as a busy one, and that is the weak side of this model for apps with very low traffic.
To test before committing to a month, hourly billing is R$ 0.05 an hour on Basic (0.5 vCPU and 512 MB) and R$ 0.018 an hour on DB-Starter, plus disk. Sign-up asks for a Brazilian CPF or CNPJ, a mobile number and an address in Brazil. Health checks and metrics start at Premium.
Latency between the function and the database: why distance matters
Every database query is a round trip over the network. A page that runs five queries in sequence pays five round trips before it starts responding, and that time adds up to what the user already spends reaching the server. That is why the rule Vercel writes in its own regions documentation is blunt: functions should run in the same region as the database, or as close to it as possible, for the lowest latency. We do not publish a millisecond figure here because it depends on each provider’s network path; what can be said safely is the order of magnitude: a database in the same region costs little per query, a database on another continent costs a lot.
The trap on Vercel is the default region. Every new project starts with functions in Washington (iad1). If you create the Neon database in São Paulo and forget to change the function region, every query travels from the northern hemisphere to the southern one and back. The reverse also happens: a function in gru1 with a database created in Neon’s default region outside Brazil. Check both regions before you measure anything.
The second issue is connections. Functions that come and go tend to open many short PostgreSQL connections. Neon handles this with PgBouncer, which accepts up to 10,000 client connections, and recommends the pooled connection string for serverless setups. In a continuous server, the pool lives inside the Node.js process, and you size it to the database plan’s limit: on Zenifra, 15 connections on DB-Starter, 72 on DB-Basic, 147 on DB-Premium and 598 on DB-Enterprise, summed across all app instances.
The third issue is a database that sleeps. On Neon’s Launch plan, compute is suspended after 5 minutes without use unless you turn off scale to zero. The first query after that waits for compute to come back. That is a good deal for projects that sit idle at night and a problem for an API that has to answer quickly at any hour. To measure your own case, log the time of each query in the app logs (for example, with performance.now() before and after the call) at peak and off-peak hours, on both platforms.
What works and what changes outside Vercel
Almost everything works the same with next start. The Next.js self-hosting documentation says image optimization with next/image and Proxy (the former middleware, renamed in Next.js 16) work with zero configuration. Zenifra’s documentation confirms the list on its side: server rendering, API routes, Server Actions, middleware or proxy.ts, and next/image work without an adapter. The table below shows what needs attention.
| Feature | On Vercel | With next start on Zenifra |
|---|---|---|
| Server rendering and API routes | Vercel Functions per route | A single Node.js server handles every route |
| Image optimization (next/image) | Billed per transformation above the allowance | Works with next start; remote domains must be listed in images.remotePatterns |
| Middleware / proxy.ts | Runs in every Vercel region | Runs in the same server, no configuration |
| Server Actions | Work | Work; with more than one instance, set the same NEXT_SERVER_ACTIONS_ENCRYPTION_KEY on all of them |
| ISR and data cache | Cache managed by the platform | Cache on each instance’s disk; with several instances, use a shared cacheHandler |
| runtime = "edge" | Runs on the Edge Runtime | Remove the line; the route runs on the Node.js runtime |
| Cron Jobs in vercel.json | A GET request to a route | A scheduled job that runs a command |
| VERCEL_URL, VERCEL_ENV variables | Injected by Vercel | Do not exist; replace them with your own variables, such as APP_URL |
Caching is the item that surprises people most. According to Next.js, ISR and the data cache live by default on the local disk of each instance. With one instance, they behave as expected. With two or more, each instance keeps its own copy, and revalidatePath or revalidateTag only affect the instance that received the call. The way out is to run one instance or configure a cacheHandler that stores entries in shared storage, such as Zenifra’s managed cache (Valkey); Next.js maintains a Redis example as a reference.
With several instances, Next.js also asks for the same encryption key on all of them for Server Actions (NEXT_SERVER_ACTIONS_ENCRYPTION_KEY, set at build time), otherwise you get the "Failed to find Server Action" error, and it recommends configuring a deploymentId to avoid version skew while a deploy rolls out. On Zenifra, project variables are available during the build, so you can register the key as a regular variable. Files uploaded by users cannot go on the instance disk, which is wiped on every deploy: use Armazém, which is S3-compatible, or persistent storage.
How we built the cost estimate
Comparing a function billed per GB-hour with a fixed-price instance requires assumptions. Ours are below, and you can replace every number with your own. Vercel and Neon prices were read on the official pages on 11/06/2026; Zenifra’s came from the public plan catalog on the same day. The conversion uses the PTAX selling rate of 11/05/2026, R$ 5.4621 per dollar, published by Brazil’s Central Bank, plus the 3.5% IOF tax on international card purchases (Decree 6,306/2007, art. 15-B, item VII, as amended by Decree 12,499/2025). The card issuer’s spread is not included and usually pushes the real statement a little higher.
We assumed functions with the default 2 GB of memory in the gru1 region and Neon on the Launch plan, in the São Paulo region. The US$ 20 Pro credit was applied only to Vercel usage, and the Neon database was billed using Neon’s own price table. On Zenifra, the estimate uses the monthly app plan, the monthly PostgreSQL plan and database disk at R$ 0.20 per GB per month, the value the public calculator applies to the PostgreSQL volume. The formulas:
- Vercel = US$ 20 + max(0; usage − US$ 20), where usage = GB-hours × US$ 0.0183 + active CPU hours × US$ 0.221 + millions of invocations × US$ 0.60.
- Neon = CU-hours × US$ 0.106 + stored GB × US$ 0.35. CU-hours = average size in CU × hours the compute is running in the month.
- Card amount = dollar total × R$ 5.4621 × 1.035.
- Zenifra = app plan × instances + PostgreSQL plan + database GB × R$ 0.20, in reais, with no exchange rate and no IOF.
- A 730-hour month. Outbound traffic is left out: Pro includes its CDN at a flat rate and Neon Launch includes 500 GB of egress per project.
Monthly cost in three app sizes
The three sizes stand for an MVP, a product with paying customers and a SaaS running two instances. In each one, the Vercel with Neon column shows the dollar total, the amount converted at PTAX and the amount with IOF; the Zenifra column shows the total in reais with the equivalent plans.
| Size | Usage assumptions | Vercel Pro + Neon | On a card (PTAX + IOF) | Zenifra (plans) | Zenifra in reais |
|---|---|---|---|---|---|
| Small | 2 GB function alive 365 h/month (730 GB-h), 5 h of active CPU, 1 million invocations; Neon 0.25 CU running 365 h and 2 GB | US$ 30.37 (US$ 20.00 for Vercel, with US$ 15.06 of usage covered by the credit, + US$ 10.37 for Neon) | R$ 165.90 / R$ 171.70 | Basic (0.5 vCPU, 512 MB) + DB-Starter (0.3 vCPU, 256 MB) + 2 GB | R$ 42.20 |
| Medium | 2 GB function alive 730 h (1,460 GB-h), 40 h of active CPU, 5 million invocations; Neon 0.25 CU (about 1 GB) always on and 10 GB | US$ 61.40 (US$ 38.56 for Vercel + US$ 22.85 for Neon) | R$ 335.39 / R$ 347.13 | Premium (1 vCPU, 1 GB) + DB-Basic (1 vCPU, 1 GB) + 10 GB | R$ 114.80 |
| Large | Two 2 GB functions alive 730 h (2,920 GB-h), 150 h of active CPU, 20 million invocations; Neon 0.5 CU (about 2 GB) always on and 50 GB | US$ 154.78 (US$ 98.59 for Vercel + US$ 56.19 for Neon) | R$ 845.40 / R$ 874.99 | 2 × Premium Plus (2 vCPU, 2 GB) + DB-Premium (2 vCPU, 2 GB) + 50 GB | R$ 379.70 |
In the small size, the estimated function usage (US$ 15.06) fits inside the Pro credit, so Vercel only charges the fixed US$ 20. We assumed Neon with scale to zero on, awake half of the month. If your traffic is even lower, Neon charges less; if the database cannot sleep, compute goes up to US$ 19.35. On the Zenifra side, DB-Starter has 256 MB, less memory than Neon’s smallest compute.
In the medium size, provisioned memory becomes Vercel’s largest item: 1,460 GB-hours cost US$ 26.72 on their own. In the large size, the two instances and 150 hours of active CPU push usage to US$ 98.59. Note that we compared 2 GB functions with 1 GB instances in the medium size, because 2 GB is the function’s smallest default option; if your app needs 2 GB per instance on Zenifra too, swap Premium for Premium Plus and the medium total becomes R$ 171.80.
The Vercel and Neon figures are estimates: they depend on how long instances stay alive, on CPU usage and on the size the database reaches with autoscaling. Zenifra’s figures are list prices. To check, run your app for a few weeks and read the Vercel and Neon usage dashboards, and build the same scenario in the Zenifra calculator using the links below.
Step by step: Next.js from GitHub with managed PostgreSQL
The path below follows Zenifra’s documentation. Before you start, make sure the project runs locally with npm ci && npm run build && npm start and that package-lock.json is committed at the repository root (or in the configured root directory). Installation uses npm ci; if the project uses pnpm or Yarn, generate a compatible package-lock.json or deploy an OCI image. An owner of the organization has to connect the GitHub account and install the Zenifra GitHub App.
Start with the database. In the Console, click Create project, choose PostgreSQL, the plan and the version (15 to 18; the default is 18). The user and the database are both called app, and the password is shown only once at the end of creation: copy the connection URI at that moment. It has the format postgresql://app:<password>@postgresql-<id>.managed.zenifra.com:<port>/app?sslmode=require and turns TLS on.
Then create the app. Click Create project, choose HTTP Application and, under Advanced Settings, select Git Repository as Project Source and GitHub as Git Provider. Choose the repository, the branch, the Node.js runtime with the same major version you use locally (20, 22, 24 or 26) and fill in the fields below. The initial update mode is Automatic by branch: every push to the branch publishes a new version.
| Console field | Value with next start | Value with standalone output |
|---|---|---|
| Port | 3000 | 3000 |
| pre-build | empty | empty |
| build | npm run build | npm run build && cp -r public .next/standalone/ && cp -r .next/static .next/standalone/.next/ |
| start | npx next start -H 0.0.0.0 -p 3000 | node .next/standalone/server.js |
| Variables | DATABASE_URL and the NEXT_PUBLIC_* ones | DATABASE_URL, NEXT_PUBLIC_*, HOSTNAME=0.0.0.0 and PORT=3000 |
DATABASE_URL is not injected automatically: add the variable to the app project with the database URI. The Console URI works unchanged with the pg driver (node-postgres) and with postgres.js. Do not switch it to sslmode=disable: the database requires TLS by default.
Project variables are available during the build, so NEXT_PUBLIC_* works. Saving a variable restarts the instances but does not rebuild: if you changed a NEXT_PUBLIC_* value, use New build under Build logs or push a commit. Click Create Project, follow the Build logs and, once the project is Running, open the *.clients.zenifra.com URL. From Premium up, configure the health check on a lightweight route such as /api/health, and allow that route in the middleware matcher if it requires login.
Prisma or Drizzle migrations at build and start
Two moments matter. At build time, the ORM client has to be generated. With Prisma, prisma generate usually sits in postinstall; if it does not, use npx prisma generate && npm run build in the build field. At run time, migrations should run at the beginning of start, when the app already has access to the project network. Zenifra’s documentation recommends this format:
- Prisma ORM 8: the Prisma documentation states that npx prisma db migrate replaces prisma migrate deploy; use the command for the version installed in your project.
- With standalone output, replace the last part with node .next/standalone/server.js and make sure the ORM CLI is available in the instance.
# Prisma ORM 7: start command
npx prisma migrate deploy && npx next start -H 0.0.0.0 -p 3000
# Drizzle: start command (migrations generated beforehand with drizzle-kit generate)
npx drizzle-kit migrate && npx next start -H 0.0.0.0 -p 3000With more than one instance, all of them run start. Prisma serializes migrate deploy with a database lock, but a long migration delays the startup of every instance. For large changes, such as creating indexes on big tables or moving data, apply the migration beforehand from a machine with database access, and deploy the code afterwards.
Also remember that rolling back the app does not undo database changes. If a new version adds a required column, moving the code back to the previous commit can break inserts. Prefer migrations that stay compatible with the previous version (add an optional column, deploy, backfill, and only then make it required), and keep your own pg_dump exports in addition to the plan’s automatic backups.
When staying on Vercel makes more sense
Vercel is built by the team that maintains Next.js, and it shows in the details: ISR and caching managed without you configuring anything, Preview Deployments, a global CDN with more than 126 points of presence, a Firewall, and functions that can run in 19 regions. If your audience is spread around the world, or if most pages are static and served from the CDN, the function bill stays small and the Vercel experience is worth the price in dollars.
It also wins when traffic is very irregular. An app that gets visits during a few hours of the day, or sits idle on weekends, pays for memory only while there are requests, and Neon with scale to zero turns the database off during dead hours. In the small size of our estimate, that is exactly what kept usage below the Pro credit. If you already use platform-specific features such as Edge Config, Vercel Blob or the AI Gateway, migrating has an engineering cost that belongs in the decision.
A continuous server in Brazil makes more sense when the app talks to the database a lot, stays busy for much of the day and mainly serves users in Brazil. In that profile, memory billed per GB-hour and CPU billed in dollars add up, and a fixed price in reais, paid by PIX, boleto or card with no IOF, is more predictable. A mix also works: some teams keep the static frontend on Vercel and run the API and the database in Brazil.
Does Vercel have servers in Brazil?
It has a function region in São Paulo, gru1, but it is not the default. New projects start in Washington (iad1), and you have to pick gru1 under Function Regions in the settings or in the regions key of vercel.json.
The database is bought separately, through the Marketplace. On Neon, choose the aws-sa-east-1 region so the function and the database sit in the same region. Vercel’s CDN serves static files from the point of presence closest to the user, regardless of the function region.
Do I need standalone output to run Next.js outside Vercel?
No. npx next start -H 0.0.0.0 -p 3000 already runs every Next.js feature. output: "standalone" is optional and shrinks what goes to production, because it copies only the traced files and generates a minimal server.js.
If you turn it on, copy the public and .next/static folders into .next/standalone during the build, since server.js does not do that by itself, and set HOSTNAME=0.0.0.0 and PORT=3000 in the project variables. In monorepos, Next.js uses the project folder as the tracing root; files outside it need outputFileTracingRoot.
// next.config.js
module.exports = {
output: 'standalone',
}# Build and start with standalone output
npm run build && cp -r public .next/standalone/ && cp -r .next/static .next/standalone/.next/
node .next/standalone/server.jsDo ISR and revalidatePath work with several instances?
They work per instance. Without extra configuration, each instance keeps its own cache on disk, and revalidatePath or revalidateTag only clear the cache of the instance that received the call.
With one instance, the behavior is what you expect. With two or more, configure a cacheHandler that writes to shared storage, such as a managed Valkey, and turn off the in-memory cache with cacheMaxMemorySize: 0, as shown in the Next.js self-hosting guide. For the App Router with several instances, the guide also asks for tag coordination through the handler’s refreshTags() method.
How do I move the Neon database to Zenifra PostgreSQL?
With pg_dump at the source and pg_restore at the destination. Databases from the Vercel Marketplace belong to the original provider, so the export is done directly on Neon, with its connection string.
Create the PostgreSQL database on Zenifra before the app, restore the dump, add the new DATABASE_URL to the project and validate the app on its *.clients.zenifra.com URL. Keep the Vercel project online until you switch DNS and remove it only after a few days, so you can roll back. Zenifra’s migration guide has the cutover-day checklist, with TTL reduction and a final data copy.
Does Zenifra’s managed PostgreSQL have backups?
Yes, automatic and included in the plan, with no charge for the space. DB-Starter takes 1 backup a day kept for 7 days, DB-Basic 2 a day for 7 days, DB-Premium 2 a day for 14 days and DB-Enterprise 3 a day for 30 days.
Restores are requested from support, which restores into a new project by default. There is no restore from the Console yet and no point-in-time recovery, so also keep your own pg_dump exports of critical data.