AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

Managing Replit Deployments: Secrets, Persistent Storage, and Custom Domains

Lianne Tan · 365Finds Editorial
Indexed 88,650 Wiki articles

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

The biggest mistake developers make when deploying on Replit is assuming production behaves like the workspace.

In the interactive workspace, Replit feels comfortably stateful. You write code, test an API call, generate a local SQLite database, and upload test images directly into your project root. Everything stays right where you left it. Then, you click "Publish", push your application to a live deployment, and within days—or after the first automated redeploy—customer records vanish and uploaded files disappear into thin air.

At 365Finds, we have tracked how teams transition from rapid prototyping to production on Replit. The platform's deployment engine is not a persistent virtual server; it is a containerized, cloud-native runtime built on Google Cloud Platform. To run production applications reliably, you have to treat Replit deployments as strictly stateless compute. Here is how to configure environment secrets, persistent databases, object storage, and custom domains without getting burned.


1. Secrets Management: Isolating Dev and Production

Hardcoding credentials or committing .env files into code repositories is dangerous, especially in collaborative environments. Replit provides a dedicated Secrets tool built on top of Google Cloud Secret Manager, encrypting values at rest with AES-256 and injecting them into memory at runtime.

Workspace Secrets vs. Deployment Secrets

A frequent point of confusion is how secrets propagate. When developing inside the workspace, you use the Secrets pane (the lock icon in the sidebar). However, production deployments require deliberate credential isolation:

  1. Workspace Secrets: Intended for development and local testing. Use sandbox Stripe keys, test database connections, and test OAuth credentials here.
  2. Deployment Secrets: Configured under the Publishing / Deployments settings. These override or supplement workspace values specifically when your app runs as a live deployment.

When you trigger a deployment, Replit packages a snapshot of your project and applies the Deployment Secrets. If you update a production secret later, the change does not take effect dynamically in memory; you must republish the deployment to roll out the new environment configuration.

Accessing Secrets in Application Code

Secrets are exposed directly as standard system environment variables. You do not need proprietary SDKs to read them:

Notice REPLIT_DEPLOYMENT. Replit automatically sets this variable to '1' in live deployments. At 365Finds, we strongly recommend using this flag to enforce runtime assertions—preventing your application from booting if production keys are accidentally pointing to staging resources.

Note on Static Deployments: If you choose Replit's Static Deployment option (for plain HTML/JS or static site builds), secrets are deliberately disabled. Client-side browser code cannot safely consume server-side secrets. If your frontend requires backend APIs, deploy an Autoscale or Reserved VM backend and keep keys server-side.


2. Persistent Storage: The Ephemeral Filesystem Trap

In Replit Deployments, the container filesystem is ephemeral. Any file written to the local disk during runtime will be wiped clean when the container scales down, restarts, crashes, or receives a new build rollout.

+-------------------------------------------------------------------+
|                        Replit Architecture                        |
|                                                                   |
|   Workspace (Stateful IDE)          Deployment (Stateless Run)     |
|   +-----------------------+         +--------------------------+  |
|   | Persistent Workspace  |         | Ephemeral Container Disk |  |
|   | Disk (Code & Edits)   |         | (Wiped on redeploy)      |  |
|   +-----------+-----------+         +------------+-------------+  |
|               |                                  |                |
|               | Publish Snapshot                 |                |
|               +--------------------------------->+                |
|                                                  |                |
|                      +---------------------------+                |
|                      |             |                              |
|                      v             v                              |
|           Replit Managed DB   App Storage (GCS)                   |
|           (PostgreSQL State)  (Persistent Files)                  |
+-------------------------------------------------------------------+

If your application writes user avatars to ./uploads or stores transactional data in ./database.db via SQLite, you will lose data. Production persistence requires separating relational state from unstructured asset storage.

Relational State: Replit Managed PostgreSQL

For structured records, users, and relational schemas, use Replit's native PostgreSQL database service:

Always run schema migrations as part of your deployment build command (e.g., npx prisma migrate deploy or drizzle-kit migrate), ensuring your production schema syncs before incoming traffic hits the container.

Unstructured Assets: Replit App Storage (Object Storage)

For binary files, user uploads, exports, and images, Replit provides App Storage, backed by Google Cloud Storage (GCS) buckets:

365Finds recommends App Storage over self-managed AWS S3 buckets for early-to-mid stage projects on Replit, simply because authentication and credential rotation are handled automatically by Replit's runtime without needing manual IAM key management.


3. Custom Domains and DNS Configuration

Every Replit deployment receives an assigned default URL formatted as <your-app>.<cluster>.replit.app. For professional applications, you will want a custom domain.

Linking an External Registrar Domain

You can purchase domains directly in Replit, or connect a domain purchased via third-party registrars (Cloudflare, Namecheap, GoDaddy, Porkbun):

  1. Go to your deployment view, open Publishing, and select Domains -> Connect your own domain.
  2. Enter your custom domain (e.g., app.yourdomain.com or apex yourdomain.com).
  3. Replit will generate two DNS records that you must add to your DNS provider's dashboard:
    • A Record: Points your host name to Replit's ingress IP address.
    • TXT Record: A verification string required for domain ownership validation and SSL provisioning.

Critical DNS Rules and Gotchas

At 365Finds, we regularly see two DNS pitfalls cause deployment failures:

Configuration AreaRequirementCommon Failure Mode
Apex / Root DomainMust use an A Record pointing to Replit's IP.Attempting to use a CNAME record on a root domain; RFC specifications and many DNS providers reject apex CNAMEs.
Cloudflare ProxyDNS record proxy status must be set to DNS Only (grey cloud).Keeping Cloudflare proxy active (orange cloud) blocks Replit's Let's Encrypt automated challenge, preventing SSL issuance.
SubdomainsMust configure each subdomain (app.example.com, www.example.com) individually.Expecting wildcard certificates (*.example.com); Replit does not support wildcard SSL certificates.

Once records are added, return to Replit and click Verify. DNS propagation typically takes between 5 to 30 minutes, though registrar delays can extend up to 48 hours. Replit automatically issues and maintains TLS/SSL certificates via Let's Encrypt without manual certificate renewals.


4. Architectural Choice: Autoscale vs. Reserved VM

Replit provides multiple deployment execution models. Selecting the wrong model undermines your storage and lifecycle assumptions:

365Finds prefers Autoscale paired with Replit Managed PostgreSQL and App Storage for transactional web apps, as it delivers high cost-efficiency. If your app relies on persistent WebSocket connections or continuous cron schedules, choose Reserved VM.

Deploying production software on Replit succeeds when you abandon the illusion of a monolithic server and embrace stateless cloud containers. Configure your secrets in the Deployment panel, redirect every state write to PostgreSQL or App Storage, set your Cloudflare records to DNS-only, and verify that REPLIT_DEPLOYMENT === '1' before accepting customer traffic.

References