/how-to-build-replit

How to Build a Customer portal with Replit

Learn how to build a powerful customer portal using Replit. Follow our step-by-step guide to create, design, and launch your secure online portal easily.

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

How to Build a Customer portal with Replit

A simple and reliable way to build a Customer Portal with Replit is to use a Node.js + Express backend combined with HTML/JS frontend. On Replit, you can keep everything in one project (Repl) — backend code running under server.js, static files in a "public" folder, and secrets stored via Replit’s built-in "Secrets" tool (lock icon on the left sidebar). Replit automatically runs your server when you hit the "Run" button, giving you a live URL where your customer portal is hosted. You can later connect it to a real database (like Replit DB, SQLite, PostgreSQL via connection string) and add authentication with tools like Passport.js or Firebase.

 

Step-by-Step setup of a basic customer portal in Replit

 

Create a new Node.js Repl.

This prepares a working environment with a pre-configured runtime. Replit will automatically install and manage dependencies from package.json.

 

  • In your Files sidebar, you’ll see a file called index.js. Rename it to server.js (just right-click → Rename).
  • Create a folder named public for your frontend files (HTML, CSS, JS).
  • Create a file inside public named index.html.

 

Install Express and other dependencies

 

npm install express

 

Replit automatically runs npm install whenever you edit package.json, but you can also run it manually in the Shell tab.

 

Basic server setup (in server.js)

 

// server.js

const express = require("express")
const app = express()
const PORT = process.env.PORT || 3000

// Middleware to serve static frontend files
app.use(express.static("public"))

// Example API endpoint: fetch customer data
app.get("/api/customers", (req, res) => {
  // In real life, you would pull this from a database
  const customers = [
    { id: 1, name: "Alice", email: "[email protected]" },
    { id: 2, name: "Bob", email: "[email protected]" }
  ]
  res.json(customers)
})

// Start server
app.listen(PORT, () => {
  console.log(`Server running on port ${PORT}`)
})

 

Place the above code in server.js. Replit will automatically expose it on a public URL once you click Run. You can open the link and it will serve the "public/index.html" page by default.

 

Frontend (public/index.html)

 

<!DOCTYPE html>
<html>
  <head>
    <title>Customer Portal</title>
    <meta charset="UTF-8" />
    <style>
      body { font-family: Arial, sans-serif; margin: 40px; }
      h1 { color: #333; }
      .customer { margin: 8px 0; }
    </style>
  </head>
  <body>
    <h1>Customer Portal</h1>
    <div id="customers"></div>

    <script>
      // Fetch customer data from backend API
      fetch("/api/customers")
        .then(res => res.json())
        .then(data => {
          const list = document.getElementById("customers")
          data.forEach(customer => {
            const div = document.createElement("div")
            div.className = "customer"
            div.textContent = `${customer.name} (${customer.email})`
            list.appendChild(div)
          })
        })
        .catch(err => console.error(err))
    </script>
  </body>
</html>

 

This HTML automatically calls your backend API and lists customers. Keep this file in the public folder.

 

Managing Secrets on Replit

 

  • Open the Secrets tab (lock icon on left sidebar).
  • Add entries like DATABASE_URL, JWT_SECRET, or API\_KEY — Replit keeps them secure and available via process.env in your code.

 

// Example usage of a secret key (in server.js)
const apiKey = process.env.API_KEY // Stored in Replit Secrets
console.log("Loaded API key:", apiKey ? "OK" : "Missing")

 

Connecting to a Database

 

  • For quick demos, you can use Replit's built-in Replit DB (simple key-value database).
  • Install with npm install @replit/database

 

// Example of basic Replit DB usage (add this under other routes)
const Database = require("@replit/database")
const db = new Database()

app.get("/api/add-customer/:name", async (req, res) => {
  const newName = req.params.name
  await db.set(newName, { name: newName })
  res.send(`Customer ${newName} added!`)
})

 

Common Replit Gotchas & Tips

 

  • Don’t run your server with node manually (Replit runs server automatically based on the "Run" script in package.json).
  • Add ".replit" and "replit.nix" files carefully — these define how the environment runs. For Node apps, Replit auto-generates these correctly most of the time.
  • Limits: Replit free hosting sleeps after inactivity. For persistent, always-on portals, consider upgrading to Replit Hacker plan or exporting code to another host later.
  • Collaboration: You can invite teammates in “Multiplayer” mode, and you’ll code together in real-time just like Google Docs.

 

With these steps, you have a working customer portal that runs entirely in Replit — backend serving APIs, frontend fetching from it, secrets safe, and deploy URL live for testing.

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Contact Us

How to Securely Update Customer Profiles with Express.js and Replit Secrets




How to Sync Customer Data with Stripe in Your Replit Customer Portal




How to Create a Magic Link Login API for Your Customer Portal on Replit




Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Contact Us
Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Best Practices for Building a Customer portal with Replit

Building a customer portal on Replit works best when you treat Replit as a lightweight cloud dev environment, not a full production server. Use Replit for prototyping or internal tools, not for storing real customer data or handling live payments. Combine a simple server (Node.js or Flask) with a dynamic frontend (React or plain HTML/JS), connect to a database through Replit’s built-in features (like Replit DB or an external Postgres), and use environment variables stored under the “Secrets” tab for API keys and passwords. Serve both the frontend and backend from the same Repl at first — later, you can deploy it externally if you need scaling or persistence guarantees.

 

Project Structure

 

Create a Node.js Repl and organize your files like this:

  • index.js: your backend (Express server)
  • public/: static frontend files like HTML, CSS, and JS
  • views/: templates if you use templating engines
  • replit.nix: automatically managed by Replit; leave as is
  • .replit: configures run commands; you can adjust it if needed

 

npm init -y
npm install express dotenv
mkdir public

 

Setup Express Server

 

Inside your index.js (root level of the Repl), start a simple Express app which serves the customer portal interface and handles backend logic:

 

// index.js
import express from "express"
import dotenv from "dotenv"

dotenv.config() // Loads secrets from Replit's Secrets tab
const app = express()
const PORT = process.env.PORT || 3000

app.use(express.static("public")) // Serves your frontend files
app.use(express.json()) // Allows handling of JSON requests

// Example route: fetch customer profile data
app.get("/api/customer/:id", (req, res) => {
  // Simulate fetching user data; replace with DB query in real use
  const customer = { id: req.params.id, name: "Alice Example", email: "[email protected]" }
  res.json(customer)
})

// Basic root route
app.get("/", (req, res) => {
  res.sendFile("/public/index.html", { root: "." })
})

app.listen(PORT, () => console.log(`Server running on port ${PORT}`))

 

Create a Simple Frontend

 

Inside the public folder, create index.html that talks with your backend API.

 

<!-- public/index.html -->
<!DOCTYPE html>
<html>
  <head>
    <title>Customer Portal</title>
    <meta charset="utf-8" />
    <style>
      body { font-family: Arial; padding: 20px; }
      #result { margin-top: 20px; }
    </style>
  </head>
  <body>
    <h1>Customer Portal</h1>
    <input id="custId" type="text" placeholder="Enter your customer ID" />
    <button id="loadBtn">Load Customer Info</button>

    <div id="result"></div>

    <script>
      const loadBtn = document.getElementById("loadBtn")
      const result = document.getElementById("result")

      loadBtn.onclick = async () => {
        const id = document.getElementById("custId").value
        const res = await fetch(`/api/customer/${id}`)
        const data = await res.json()
        result.innerHTML = `<p><b>Name:</b> ${data.name}<br><b>Email:</b> ${data.email}</p>`
      }
    </script>
  </body>
</html>

 

Using Replit Secrets

 

In Replit’s left sidebar, click the lock icon (⚙️ Secrets). Add variables like:

  • DB\_URL: your database connection string
  • API\_KEY: if you use external services

These become available as process.env.DB\_URL in your Node code. Never hardcode them directly in code.

 

Connecting a Database

 

Replit DB works for small projects. For anything user-based, prefer an external managed DB like Neon Postgres or MongoDB Atlas. Example with Replit DB:

 

npm install @replit/database

 

// add inside index.js, after imports
import Database from "@replit/database"
const db = new Database()

// Example storing user
app.post("/api/customer", async (req, res) => {
  const { id, name, email } = req.body
  await db.set(id, { name, email })
  res.json({ success: true })
})

 

Deployment and Collaboration

 

Replit Deployments (if your account supports it) let you run this continuously, independent from the editor environment. Use the “Deploy” button → “HTTP Server” option.

If you’re collaborating, enable Multiplayer (top-right “Invite” button). Replit handles live coding for multiple teammates, but be careful with concurrent installs and restarts — have one person run the server at a time.

 

Common Pitfalls

 

  • Sleep on inactivity: Free Repls go to sleep; use Deployments if you need uptime.
  • Secrets exposure: Never post .env or key values in code output or console logs.
  • Limits: Filesystem changes (uploads, local DB files) may not persist — use Replit DB or external storage.
  • Git: Use Replit’s built-in Git tab or connect to GitHub, but avoid including node\_modules in the repo.

 

By following this flow — Express backend, static frontend in public, Replit secrets, and database integration — you can smoothly build a working customer portal prototype directly inside Replit while keeping your setup maintainable and secure.

Client trust and success are our top priorities

When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.

Rapid Dev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with. They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

CPO, Praction - Arkady Sokolov

May 2, 2023

Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost. He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Co-Founder, Arc - Donald Muir

Dec 27, 2022

Rapid Dev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space. They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Co-CEO, Grantify - Mat Westergreen-Thorne

Oct 15, 2022

Rapid Dev is an excellent developer for no-code and low-code solutions.
We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Co-Founder, Church Real Estate Marketplace - Emmanuel Brown

May 1, 2024 

Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 
This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Production Manager, Media Production Company - Samantha Fekete

Sep 23, 2022