Moving a Next.js app from Vercel to Prostack Cito

A Next.js app that runs on Vercel will run on a server too, and most of it needs no changes. What needs attention is everything Vercel was doing around the app, such as previews, cron, storage and environment variables. Here’s what replaces each of those on Prostack Cito, and the order to move things in.

Updated · All guides

What carries over as it is

Prostack Cito runs a Next.js app as one long-lived Node.js process, the way next start does. Next.js’s own self-hosting guide lists what works that way with no configuration:

  • Image optimisation through next/image. It uses your server’s CPU and memory now, where it used Vercel’s before.
  • Middleware, which recent versions of Next.js call Proxy.
  • Caching and ISR. The cache is kept on the server’s disk, which is the setup Next.js expects for a single server.
  • after, for work that runs once the response has gone.

Your pages, route handlers and Server Actions are the app itself, and behave as they do under next start on your laptop.

What Vercel was doing for you

On Vercel On Prostack Cito
A preview deployment for every branch Clone the site to a staging copy and deploy the branch there. Previews aren’t created for you per pull request.
Vercel Cron, set in vercel.json A cron job on the site that calls the same route
Environment variables in the dashboard, per environment One .env file in the site’s folder, and another on each staging site
Instant rollback to an earlier deployment git revert and deploy again, with nightly backups for what git doesn’t hold
Serverless functions with a time limit One Node.js process that stays up and keeps its database connections
A global edge network One server, in the UK or the US. Put Cloudflare in front if your users are far from it.
Vercel Analytics Traffic for each site in Cito, read from the server’s access logs
Vercel’s firewall A firewall and web application firewall on the server, which we look after

Each of those has a guide: deploying, environment variables and rolling back.

What to change in the code

Most apps need a few small edits. Your agent can make them, and searching the project for vercel finds nearly all of them.

  • VERCEL_URL, VERCEL_ENV and the other VERCEL_ variables. Vercel sets these itself, so they’re empty on any other host. Replace them with a variable of your own, such as APP_URL in .env.
  • vercel.json. Nothing reads it once you’ve left. Move its redirects, rewrites and headers into next.config.js, and its crons into cron jobs on the site.
  • @vercel/analytics and @vercel/speed-insights. They report to Vercel’s own services. Take the components out.
  • maxDuration and similar function settings. There’s no function to configure, so they do nothing. A long request is limited by the server’s own timeouts instead.

Storage and databases

Storage you added through Vercel is reached with a token or a connection string, so the app can keep using it from the new server. That goes for a Postgres or Redis database from its Marketplace, and for Vercel Blob. Blob needs one extra step: on Vercel the app signs in to it automatically, and anywhere else it needs a read-write token (BLOB_READ_WRITE_TOKEN), which you add to the store’s connection in the Vercel dashboard.

A Postgres database can move onto the server too: a Prostack Cito server runs MySQL (MariaDB) or Postgres, and the nightly backups and monitoring cover either one. Redis is on every Prostack Cito server, so a cache or queue can move across. Files that aren’t in git carry across every Git deploy, so an app can write uploads to a folder in the site, and they’re in the nightly backup with the rest of it.

Some of these services are billed through your Vercel account. Check each one before you close it.

Copy the environment variables

The Vercel CLI writes a project’s variables to a file:

vercel env pull --environment=production .env.vercel

Go through the file before you use it. Take out the VERCEL_ lines, and fill in what’s missing: variables saved as Secret (Vercel used to call them Sensitive) are write-only, so those values come from wherever they were issued. Then put the result on the server as ~/public_html/.env, and delete the copy on your machine.

NEXT_PUBLIC_ values are written into the browser’s JavaScript at build time, so they need to be in .env before the first build.

Give the build some room

On Vercel the build ran on their machines. On Prostack Cito, next build runs on your server, and it’s usually the most memory the app ever asks for. 2GB is tight for a Next.js build. The readiness audit reads your project and suggests a server size.

The order to move in

  1. Set the site up. Create a Node.js site, connect the repository and add app.js. Deploying a Next.js app has the steps.
  2. Add .env and deploy. Build, restart, and open the site’s preview URL.
  3. Check it while Vercel is still live. Both copies are now talking to the same database, so test with care. Sign-in through Google, GitHub or another provider may fail on the preview URL until you add that URL to the provider’s allowed list.
  4. Leave cron jobs until the switch. If they run on both hosts, every scheduled email goes out twice. Add them on Prostack Cito, and remove them from Vercel, at the moment you move DNS.
  5. Move DNS. If the domain uses Vercel’s nameservers, move its DNS somewhere else first. We recommend Cloudflare. Webhooks that call your domain, such as Stripe’s, follow it to the new server without changes.
  6. Keep the Vercel project for a few days. It’s your way back if something turns up. Remove it once you’re sure.

If your app runs on Prostack Cito as it is, we do this move for you, free of charge: we set up app.js, copy the app across, and schedule the go-live with you once you’ve checked it on the preview URL. How we take an app on explains it.

What you give up, and what you get

You lose a preview for every pull request, a rollback that takes one click, and an edge network that puts the app near every visitor. A server also has a fixed size. It doesn’t scale itself for a spike, and moving up a plan is a resize that we handle.

In return the bill is a fixed monthly price per server, with no per-request charges, and one server runs as many apps as it has room for. The operating system is patched every night, and there are people watching the server around the clock who answer when it breaks. Pricing has the plans.

More guides

Everything in the Cito control panel, setting by setting, is in the Cito documentation.

Rather we did the move?

If your app runs on Prostack Cito as it is, we move it for you, free.