AI-built apps

Deploy a Replit app to Zenifra

You can keep building the app on Replit and publish it on Zenifra. The code goes to a GitHub repository, and Zenifra builds and publishes from it. Almost everything the Zenifra console asks for is already in the project's .replit file.

1. Push the code to GitHub

On Replit, link your GitHub account in your account's connected services. Then open the Git tool in the project and connect a repository:

  • To send changes, commit and click Push in the Git pane.
  • To keep the repository in step with Replit without clicks, turn on auto-sync in the Git pane. It syncs both ways.
  • If sync stops, reconnect GitHub in connected services. Replit recommends a fine-grained personal access token for a more reliable connection.

Details in Replit's Git documentation.

2. Copy the settings from the .replit file

.replit sits at the repository root. A Node.js app built by Agent usually has something like this:

.replit
modules = ["nodejs-20", "web", "postgresql-16"]

[deployment]
deploymentTarget = "autoscale"
build = ["npm", "run", "build"]
run = ["npm", "run", "start"]

[[ports]]
localPort = 5000
externalPort = 80

[env]
PORT = "5000"

Each part maps to a field in the Zenifra console:

In .replitIn the Zenifra consoleIn the example
modules: nodejs-20, python-3.11, etc.Runtime and VersionNode.js, version 20
[deployment] › buildBuild Command, with the parts joined by spacesnpm run build
[deployment] › runStart Commandnpm run start
[[ports]] › localPortPort5000
[env]Environment VariablesPORT=5000
modules: postgresql-16A managed PostgreSQL, in step 4DATABASE_URL

If [deployment] has no build, leave Build Command empty. If run is ["sh", "-c", "cd main && python app.py"], use cd main && python app.py as the Start Command, or set Root directory to main and use python app.py.

Zenifra offers Node.js 20, 22, 24, and 26 and Python 3.11, 3.12, 3.13, and 3.14. See Runtimes.

Replit secrets

Values from Replit's Secrets tool do not go to GitHub. Open Secrets on Replit and add each one in Environment Variables on Zenifra. The DATABASE_URL of Replit's database does not show in Secrets; on Zenifra, it comes from the new database in step 4.

3. Create the project on Zenifra

In the console, click Create project, choose HTTP Application and the plan. In Source and port, set Project Source to Git repository, Git provider to GitHub, and pick the repository and branch. If this is your first time, connect your GitHub account and install the Zenifra GitHub App on the repository.

Fill in the fields with the table from step 2. On the Node.js runtime, Zenifra installs dependencies with npm ci, which needs a package-lock.json in the repository. Replit Node.js apps usually already have it; see Node.js dependencies.

The application must listen on 0.0.0.0 and on the project port. Agent apps already read the PORT variable, so add PORT with the same value as the Port.

4. Bring the database

If .replit has a postgresql-* module, the app uses Replit's PostgreSQL through the DATABASE_URL variable.

  1. Create a managed PostgreSQL in the same organization.
  2. Copy the database connection URI and add it as DATABASE_URL in the application project. See Connect to the database.
  3. Copy the data from Replit's production database with pg_dump and pg_restore, as in Migrate the database. For the source URI, open Replit's Database tool, pick the production database, and copy the Connection string from the Settings tab.

Check the connection file, usually server/db.ts. Older Replit apps use the @neondatabase/serverless driver, which connects over WebSocket to Neon's proxy and does not work with a regular PostgreSQL. Switch to pg with Drizzle:

server/db.ts
import pg from 'pg'
import { drizzle } from 'drizzle-orm/node-postgres'
import * as schema from '@shared/schema'

export const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL })
export const db = drizzle({ client: pool, schema })

Install the driver with npm install pg and commit package.json and package-lock.json.

5. Publish and test

The first build starts as soon as you create the project. Follow it in Build logs and, when it finishes, open the project URL. Test a screen that reads from the database and one that writes. From then on, every push to GitHub publishes a new version; see Auto deploy.

Replit features

Some features Replit apps use are Replit services:

  • Replit Auth: sign-in uses the visitor's Replit account. Before switching the domain, check in Replit's documentation whether your app's sign-in works outside Replit, or switch to your own sign-in.
  • App Storage: files live in Replit's storage. To store files on Zenifra, use the S3-compatible Armazém.
  • Scheduled tasks: become Scheduled Jobs.

Custom domain

Once the app works on the Zenifra URL, point your domain to the project. See Custom domains.

Common problems

SymptomLikely causeWhat to do
The build fails while installing dependenciesNo package-lock.json in the repository, or the file is out of syncRun npm install locally and commit package-lock.json
The application fails the health checkThe Port differs from the port the app listens onUse the .replit localPort as the Port and in PORT
The app exits with DATABASE_URL must be setThe database variable is missingAdd DATABASE_URL with the managed PostgreSQL URI
WebSocket error when connecting to the database@neondatabase/serverless driverSwitch to pg, as in step 4

Last updated on

On this page