Get your dream built 10x faster

Replit and Salesforce Integration: 2026 Guide

We build custom applications 5x faster and cheaper 🚀

Book a Free Consultation
4.9
Clutch rating 🌟
600+
Happy partners
17+
Countries served
190+
Team members
Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Stuck on an error? Book a 30-minute call with an engineer and get a direct fix + next steps. No pressure, no commitment.

Book a free consultation

How to Integrate Replit with Salesforce

Replit can integrate with Salesforce via its REST API or official SDKs by authenticating through OAuth 2.0 or a Salesforce Connected App. You build a small Node.js (or Python) server inside your Repl, handle the OAuth flow, obtain an access token, and then call Salesforce endpoints using HTTPS requests. You manage credentials (Salesforce client ID, client secret, refresh token, etc.) with Replit Secrets so you never hardcode them. Once your Repl is running, you can expose webhooks or test live integrations using your Repl’s public URL, provided by the mapped port (0.0.0.0 bind). This setup allows Replit to act as a lightweight middleware between your app and Salesforce—practical for prototyping and small automations.

 

Main Integration Flow

 

Salesforce offers a REST API that lets external apps (like one running in Replit) read, write, and update Salesforce data programmatically. You connect to this API as a “Connected App” using OAuth 2.0. This means Salesforce recognizes your Replit app, and you gain a secure access token that your code can use to call Salesforce endpoints.

  • 1. Create a Connected App in Salesforce → it gives you a client ID and client secret.
  • 2. Configure OAuth callback URL → this is where Salesforce redirects after login; for a Replit app, it can be your Repl’s public URL + “/callback”.
  • 3. In Replit, store CLIENT_ID, CLIENT_SECRET, and REDIRECT\_URI in Replit Secrets.
  • 4. Handle the OAuth “authorization code” flow inside your Repl’s server.
  • 5. Exchange the authorization code for an access token, then use the token for REST API calls.

 

Minimal Working Node.js Example on Replit

 

import express from "express"
import fetch from "node-fetch"

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

// Replit Secrets: set these in the Secrets manager
const CLIENT_ID = process.env.SF_CLIENT_ID
const CLIENT_SECRET = process.env.SF_CLIENT_SECRET
const REDIRECT_URI = process.env.SF_REDIRECT_URI

app.get("/", (req, res) => {
  const authUrl = `https://login.salesforce.com/services/oauth2/authorize?response_type=code&client_id=${CLIENT_ID}&redirect_uri=${encodeURIComponent(REDIRECT_URI)}`
  res.send(`<a href="${authUrl}">Connect to Salesforce</a>`)
})

app.get("/callback", async (req, res) => {
  const code = req.query.code
  const tokenUrl = "https://login.salesforce.com/services/oauth2/token"

  // Exchange authorization code for access token
  const body = new URLSearchParams({
    grant_type: "authorization_code",
    code,
    client_id: CLIENT_ID,
    client_secret: CLIENT_SECRET,
    redirect_uri: REDIRECT_URI
  })

  const response = await fetch(tokenUrl, { method: "POST", body })
  const data = await response.json()

  // Store refresh_token or access_token securely in memory or Replit Secrets if needed
  res.json(data)
})

app.get("/accounts", async (req, res) => {
  const accessToken = process.env.SF_ACCESS_TOKEN // ideally set after OAuth
  const instanceUrl = process.env.SF_INSTANCE_URL

  const response = await fetch(`${instanceUrl}/services/data/v58.0/query/?q=SELECT+Name+FROM+Account`, {
    headers: { Authorization: `Bearer ${accessToken}` }
  })
  const records = await response.json()
  res.json(records)
})

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

 

Practical Integration Notes

 

  • Use Replit Secrets: Never hardcode credentials. Keep client_secret, access_token, etc., only in Replit’s Secrets configuration.
  • Run the Repl: Replit automatically binds on 0.0.0.0 and gives you a public HTTPS URL (like https://projectname.username.repl.co) where Salesforce can redirect the OAuth callback.
  • Token Lifecycles: Salesforce access tokens expire; refresh with your refresh\_token in the background if you want ongoing access.
  • Webhook Handling: You can expose endpoints to receive outbound messages or platform events from Salesforce. The Repl must be running (not sleeping) to receive them in real time.
  • Scaling/Production: For high availability or secured production usage, move token storage and stateful jobs (like CRON syncs) to an external cloud service, then call your Replit app as a thin frontend or testing surface.

 

In Plain Terms

 

You can think of your Replit app as a tiny server that “logs in” to Salesforce on your behalf, using secure keys provided by Salesforce. Once logged in, your app can ask Salesforce for data, create new records, or update old ones—all by sending HTTPS requests. Replit just provides an easy, always-available environment to run that server, and all the actual work happens through Salesforce’s official, fully documented APIs.

Use Cases for Integrating Salesforce and Replit

1

Salesforce Data Sync Dashboard

Build a live dashboard in Replit that reads customer or sales data from Salesforce and visualizes it using a simple backend (like a Node.js + Express server) and a web frontend. The Repl connects to Salesforce’s REST API through an authenticated session, pulling information from standard objects such as Leads or Opportunities. Using Replit Secrets, you store OAuth credentials securely as environment variables. The server binds to 0.0.0.0 and runs within Replit’s runtime, so when the Repl is running, team members can open the live URL to view updated data in real time without exposing raw credentials.

  • Replit Secret Management: Save SALESFORCE_CLIENT_ID and SALESFORCE_CLIENT_SECRET in Secrets.
  • Periodic Data Pull: Use Workflows or a simple timer to refresh Salesforce records.
  • Visualization: Render the data via an Express route with HTML/JS charts.
// Example Node.js snippet to fetch Salesforce data
import express from "express";
import fetch from "node-fetch";
const app = express();

app.get("/leads", async (req, res) => {
  const resp = await fetch(`${process.env.SF_INSTANCE_URL}/services/data/v59.0/query?q=SELECT+Name+FROM+Lead`, {
    headers: { Authorization: `Bearer ${process.env.SF_ACCESS_TOKEN}` }
  });
  const data = await resp.json();
  res.json(data.records);
});

app.listen(3000, "0.0.0.0");

2

Salesforce Data Sync Dashboard

Host a webhook endpoint on Replit to receive real-time notifications from Salesforce whenever certain records change. Salesforce can send these notifications through its Outbound Messages or Platform Events. The Repl acts as the external listener that processes incoming JSON payloads (for example, updating another database or sending a Slack alert). Because Replit gives every running Repl an HTTPS URL, you can paste that URL directly into Salesforce’s webhook configuration.

  • Live Debugging: Keep the Repl open to inspect logs and test Salesforce payloads instantly.
  • Verification: Implement simple signature checks to ensure the requests are authentic.
  • Persistence: Offload processed events to an external system if you need durability beyond Replit restarts.
// Webhook listener example
import express from "express";
const app = express();
app.use(express.json());

app.post("/salesforce-webhook", (req, res) => {
  console.log("Received event:", req.body);
  // Handle updates, trigger emails, or forward data
  res.status(200).send("OK");
});

app.listen(3000, "0.0.0.0");

3

Embedded Salesforce Integration Prototyping

Develop and test Salesforce-connected microservices directly on Replit before deploying them elsewhere. A typical case is prototyping a middleware API that connects Salesforce with another SaaS, like Google Sheets or Slack. You authenticate via Salesforce’s OAuth 2.0 flow inside Replit, using the returned access token to call Salesforce’s APIs. Replit’s Workflows feature can automate startup of complementary services (e.g., a database or background task) so the whole integration runs consistently. Once working, move stateful components to a production host, keeping Replit for continuous iteration.

  • Secure Dev Env: Use Secrets for all client credentials and tokens.
  • OAuth Redirects: Point Salesforce’s callback to the Repl’s public URL for testing authorization flow.
  • API Gateway: Define REST endpoints that Salesforce or other tools can consume for small-scale automation.
// Simple OAuth callback handler in Express
import express from "express";
const app = express();

app.get("/oauth/callback", async (req, res) => {
  const code = req.query.code;
  // Exchange code for access token (fetch omitted for brevity)
  res.send("OAuth flow completed!");
});

app.listen(3000, "0.0.0.0");

Book Your Free 30‑Minute Migration Call

Speak one‑on‑one with a senior engineer about your no‑code app, migration goals, and budget. In just half an hour you’ll leave with clear, actionable next steps—no strings attached.

Book a Free Consultation

Troubleshooting Salesforce and Replit Integration

1

How to connect Salesforce API to Replit without exposing authentication tokens?

To connect Salesforce API to Replit securely, never paste your access or refresh tokens into the code. Store them in Replit Secrets (they automatically become environment variables), and your code should only read these values at runtime. Use Salesforce’s OAuth flow to generate tokens safely; if the integration needs to renew tokens, handle that through an auth callback URL in your Repl. This keeps sensitive data hidden from the public code.

 

Practical Setup Steps

 

  • In Salesforce, create a Connected App and get your Client ID and Client Secret.
  • In your Replit Secrets pane, add CLIENT_ID, CLIENT_SECRET, USERNAME, PASSWORD, TOKEN (or refresh\_token) as needed.
  • In your Node.js (or Python) app, use these values from process.env — Replit exposes them only at runtime.

 

// Example Node.js: querying Salesforce REST API securely
import axios from "axios";

const accessToken = process.env.SF_TOKEN; // stored in Replit Secrets
const instanceUrl = process.env.SF_INSTANCE_URL;

const url = `${instanceUrl}/services/data/v59.0/query?q=SELECT+Name+FROM+Account`;

axios.get(url, { headers: { Authorization: `Bearer ${accessToken}` } })
  .then(r => console.log(r.data))
  .catch(e => console.error(e));

 

This approach avoids token exposure in logs, version control, or forks. If the Repl restarts, Replit loads secrets again automatically, keeping credentials safe and persistent through runtime resets.

2

Why is the Salesforce API request failing with CORS error in Replit?

The Salesforce API request fails with a CORS error in Replit because browsers block direct client-side calls to external domains that don’t explicitly allow your Repl’s origin. Salesforce’s API is not configured to accept arbitrary front-end origins, so requests from your Replit web app’s URL get rejected before reaching Salesforce’s servers. The right fix is to make requests from a server (backend) inside Replit, not directly from client JavaScript.

 

Why this happens & how to fix

 

CORS (Cross-Origin Resource Sharing) is a browser security rule: it prevents scripts loaded from one site from reading data from another site unless that other site opts in via headers like Access-Control-Allow-Origin. Salesforce allows CORS only for registered origins under trusted apps. Replit’s preview URLs change often, so adding them to Salesforce CORS settings isn’t reliable. Instead, run your integration request from a Replit Node.js or Python backend and then call that backend from your browser code.

 

// Express backend example running inside Replit
import express from "express"
import fetch from "node-fetch"

const app = express()
app.get("/salesforce-data", async (req, res) => {
  const r = await fetch("https://your-instance.salesforce.com/services/data/v57.0/query?q=SELECT+Name+FROM+Account", {
    headers: { Authorization: `Bearer ${process.env.SF_ACCESS_TOKEN}` } // stored in Replit Secrets
  })
  const data = await r.json()
  res.json(data)
})

app.listen(3000, "0.0.0.0") // exposes port properly in Replit

 

This way CORS isn’t triggered because the browser only talks to your Replit backend, and Replit server securely communicates with Salesforce.

3

How to securely store and load Salesforce credentials using Replit Secrets?

Replit Secrets securely stores your Salesforce credentials (like client ID, client secret, username, password, and token) without hardcoding them in your code. You define each secret in the Secrets tab, and Replit makes them available as environment variables while the Repl runs. In your code, you load them through standard environment access methods. This protects credentials from exposure in shared code or public Repls.

 

Step-by-step secure setup

 

  • Open the Secrets tab (đź”’ icon) in your Replit workspace.
  • Add secrets such as SALESFORCE_CLIENT_ID, SALESFORCE_CLIENT_SECRET, SALESFORCE_USERNAME, SALESFORCE_PASSWORD, and SALESFORCE\_TOKEN.
  • Use them from code via environment variables, which ensures they never appear in your source files or Git history.

 

// Example Node.js usage
import axios from "axios";

const sfUser = process.env.SALESFORCE_USERNAME;
const sfPass = process.env.SALESFORCE_PASSWORD;
const sfToken = process.env.SALESFORCE_TOKEN;

await axios.post("https://login.salesforce.com/services/oauth2/token", {
  grant_type: "password",
  client_id: process.env.SALESFORCE_CLIENT_ID,
  client_secret: process.env.SALESFORCE_CLIENT_SECRET,
  username: sfUser,
  password: sfPass + sfToken
});

 

Tip: Never print secrets in logs or send them to the client. Only the active Repl runtime can read these env vars, making this the safest method for Salesforce credentials in Replit.

Book a Free Consultation

Schedule a 30‑Minute No‑Code‑to‑Code Consultation

Grab a quick video call to discuss the fastest, most cost‑efficient path from no‑code to production‑ready code. Zero sales fluff—just practical advice tailored to your project.

Contact us

Common Integration Mistakes: Replit + Salesforce

Using Temporary Tokens Instead of OAuth Refresh Flow

A common mistake is using a single Salesforce access token (copied once) inside Replit Secrets and expecting it to last forever. Salesforce access tokens expire quickly. The correct way is implementing the OAuth 2.0 refresh token flow — so when the token expires, your app automatically requests a new one. You store the client_id, client_secret, and refresh\_token in Replit Secrets, not the short-lived access token.

  • Replit Secrets act as your local environment storage, similar to a .env file, but persistent between runs.
  • Do not hardcode credentials. Use process.env.YOUR\_KEY in Node.js or os.environ in Python.
// Example: refreshing Salesforce token in Node.js
import fetch from "node-fetch"

const data = new URLSearchParams({
  grant_type: "refresh_token",
  client_id: process.env.SF_CLIENT_ID,
  client_secret: process.env.SF_CLIENT_SECRET,
  refresh_token: process.env.SF_REFRESH_TOKEN
})

const res = await fetch("https://login.salesforce.com/services/oauth2/token", {
  method: "POST",
  body: data
})
const json = await res.json()
console.log(json.access_token)

Missing Explicit Public URL for Webhook Verification

When testing Salesforce webhooks (like Platform Events or Outbound Messages) in Replit, many forget to expose the running server port. Salesforce will only send events to a publicly reachable HTTPS URL. Replit provides that automatically only if your server binds to 0.0.0.0 and listens on the port shown in the console. Without that, Salesforce can’t verify your endpoint.

  • Bind your web server to 0.0.0.0 in your Replit code.
  • Use Replit’s generated URL to register as the webhook endpoint inside Salesforce.
// Simple Node.js webhook listener
import express from "express"
const app = express()
app.use(express.json())

app.post("/salesforce-hook", (req, res) => {
  console.log(req.body)
  res.sendStatus(200)
})

app.listen(process.env.PORT || 3000, "0.0.0.0", () => {
  console.log("Listening for Salesforce webhook…")
})

Storing State or Cached Records Only In-Memory

Many Replit apps store Salesforce data in memory (like a JavaScript object), which disappears whenever the Repl restarts. Replit Repls aren’t persistent for runtime memory — every restart wipes it. Use Replit Database, an external PostgreSQL, or Salesforce’s own data objects to persist integration state, such as sync cursors or record IDs.

  • Never depend on memory for tokens, cache, or offsets.
  • Save essential state to a small, explicit storage system instead.
// Example: saving last sync ID into Replit DB
import Database from "@replit/database"
const db = new Database()

await db.set("lastSyncedAccountId", "001XXXXXXXXXXXX")
const lastSynced = await db.get("lastSyncedAccountId")
console.log("Resuming from:", lastSynced)

Assuming Salesforce SDK Automatically Handles API Limits

When calling Salesforce APIs directly from Replit, developers often loop through thousands of records, expecting the SDK or REST client to “just handle it.” Salesforce enforces daily and per-minute API limits. Your Replit workflow must include logic for batching requests and respecting rate limits. Otherwise, you’ll hit HTTP 403 or 429 errors.

  • Use SOQL queries with LIMIT and OFFSET or incrementally sync with a timestamp filter.
  • If integrating in a Workflow, add delays or chunk loops to stay under limits.
// Batch query accounts safely from Salesforce REST API
import fetch from "node-fetch"

const res = await fetch(`${process.env.SF_INSTANCE_URL}/services/data/v59.0/query?q=SELECT+Id,Name+FROM+Account+LIMIT+100`, {
  headers: { "Authorization": `Bearer ${process.env.SF_ACCESS_TOKEN}` }
})
const data = await res.json()
console.log("Fetched", data.records.length, "accounts")

Still stuck?
Copy this prompt into ChatGPT and get a clear, personalized explanation.

This prompt helps an AI assistant understand your setup and guide you through the fix step by step, without assuming technical knowledge.

AI AI Prompt


Recognized by the best

Trusted by 600+ businesses globally

From startups to enterprises and everything in between, see for yourself our incredible impact.

RapidDev 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.

Arkady
CPO, Praction
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!

Donald Muir
Co-Founder, Arc
RapidDev 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.

Mat Westergreen-Thorne
Co-CEO, Grantify
RapidDev is an excellent developer for custom-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.

Emmanuel Brown
Co-Founder, Church Real Estate Marketplace
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!

Samantha Fekete
Production Manager, Media Production Company
The pSEO strategy executed by RapidDev is clearly driving meaningful results.

Working with RapidDev has delivered measurable, year-over-year growth. Comparing the same period, clicks increased by 129%, impressions grew by 196%, and average position improved by 14.6%. Most importantly, qualified contact form submissions rose 350%, excluding spam.

Appreciation as well to Matt Graham for championing the collaboration!

Michael W. Hammond
Principal Owner, OCD Tech

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We’ll discuss your project and provide a custom quote at no cost.Â