# How to use multiple languages in Replit

- Tool: Replit
- Difficulty: Beginner
- Time required: 15 minutes
- Compatibility: All Replit plans (Starter, Core, Pro, Enterprise)
- Last updated: March 2026

## TL;DR

Replit supports multiple programming languages in a single project through its Nix-based environment. Add language runtimes like Python, Node.js, Go, or Rust to your replit.nix file, configure run commands in the .replit file to execute different entry points, and use language server support for syntax highlighting and autocompletion across all configured languages. This approach lets you build polyglot projects such as a Python backend with a Node.js frontend in one workspace.

## Run Multiple Programming Languages in a Single Replit Project

Replit uses Nix under the hood to manage system-level packages, which means you can install any combination of language runtimes in one project. This tutorial shows you how to configure a polyglot workspace where Python and Node.js (or any other combination) coexist, each with its own package manager, language server, and run command. This is ideal for projects that have a Python backend API and a JavaScript frontend, or that use shell scripts alongside a compiled language.

## Before you start

- A Replit account (any plan)
- A Repl created from any template or blank project
- Basic understanding of at least two programming languages
- Familiarity with the Replit Shell (accessible from Tools dock)

## Step-by-step guide

### 1. Show hidden configuration files

Replit hides its configuration files by default. To edit them, click the three-dot menu at the top of the file tree panel on the left and select Show hidden files. This reveals the .replit and replit.nix files in your project root. These two files control your entire environment: .replit defines how your project runs, and replit.nix defines what system packages are available. You will edit both to set up multi-language support.

**Expected result:** The .replit and replit.nix files appear in your file tree.

### 2. Add multiple language runtimes to replit.nix

Open the replit.nix file and add the language packages you need to the deps array. Each package follows the pkgs.packageName format. Search for exact package names at search.nixos.org/packages. For example, to use both Python 3.11 and Node.js 20 with TypeScript support, add both runtimes and their associated language servers. After saving the file, run exit in the Shell to restart the environment and load the new packages.

```
{ pkgs }: {
  deps = [
    pkgs.nodejs-20_x
    pkgs.python311
    pkgs.nodePackages.typescript-language-server
    pkgs.python311Packages.python-lsp-server
    pkgs.go_1_21
  ];
}
```

**Expected result:** Running node --version, python3 --version, and go version in Shell all return valid version numbers.

### 3. Configure the .replit file for your primary language

Open the .replit file and set the entrypoint and run command for your primary language. The entrypoint tells the editor which file to open by default, and the run command defines what happens when you click the Run button. If your main application is a Python backend, point run to your Python entry file. You can change this later or run secondary languages from the Shell.

```
entrypoint = "main.py"
run = ["python3", "main.py"]

[nix]
channel = "stable-24_05"

[[ports]]
localPort = 3000
externalPort = 80
```

**Expected result:** Clicking the Run button executes your Python entry point and output appears in the Console.

### 4. Run multiple language processes simultaneously

To run a Python backend and a Node.js frontend at the same time, use the ampersand operator in your run command to launch both as background processes. The wait command at the end keeps the parent process alive so both services stay running. Alternatively, open two Shell instances from the Tools dock and run each process in its own Shell tab for better log separation.

```
# In .replit file, run both processes:
run = "python3 api/server.py & cd frontend && npm start & wait"

# Or run them in separate Shell tabs:
# Shell 1: python3 api/server.py
# Shell 2: cd frontend && npm start
```

**Expected result:** Both the Python API and the Node.js frontend start and serve on their respective ports.

### 5. Install packages for each language

Open the Shell and install packages for each language using its native package manager. Use pip install for Python, npm install for Node.js, and go mod tidy for Go. Each package manager stores dependencies in its own standard location: requirements.txt or pyproject.toml for Python, package.json for Node.js, and go.mod for Go. This keeps dependencies isolated by language even within the same project directory.

```
# Python dependencies
pip install flask requests
pip freeze > requirements.txt

# Node.js dependencies
cd frontend
npm install express react
cd ..

# Go dependencies
cd services
go mod init myapp/services
go get github.com/gin-gonic/gin
cd ..
```

**Expected result:** All packages install without errors and appear in their respective dependency files.

### 6. Organize your project structure for multiple languages

Create a clear directory structure that separates each language's code. A common pattern is to have top-level folders for each service or language: api/ for your Python backend, frontend/ for your Node.js app, and scripts/ for any shell or utility scripts. Place shared configuration at the root. This structure makes it obvious which language each component uses and prevents package manager conflicts.

```
# Recommended project structure:
# .
# ├── .replit          (run configuration)
# ├── replit.nix       (system packages)
# ├── api/
# │   ├── server.py
# │   ├── requirements.txt
# │   └── routes/
# ├── frontend/
# │   ├── package.json
# │   ├── src/
# │   └── public/
# └── scripts/
#     └── seed_db.sh
```

**Expected result:** Your project has a clean separation between language-specific directories with shared config at the root.

## Complete code example

File: `replit.nix`

```nix
# replit.nix — Multi-language environment configuration
# This file installs system-level packages for Python, Node.js, and Go
# Search for packages at: https://search.nixos.org/packages

{ pkgs }: {
  deps = [
    # Python 3.11 runtime and language server
    pkgs.python311
    pkgs.python311Packages.pip
    pkgs.python311Packages.python-lsp-server

    # Node.js 20 runtime and TypeScript support
    pkgs.nodejs-20_x
    pkgs.nodePackages.typescript
    pkgs.nodePackages.typescript-language-server

    # Go 1.21 runtime
    pkgs.go_1_21
    pkgs.gopls

    # Common utilities
    pkgs.curl
    pkgs.jq
    pkgs.htop
  ];
}

# After editing this file:
# 1. Save the file
# 2. Open Shell from the Tools dock
# 3. Type 'exit' and press Enter
# 4. Reopen Shell — the new packages will be available
#
# Verify installation:
#   python3 --version
#   node --version
#   go version
#
# .replit run command for multi-process:
#   run = "python3 api/server.py & cd frontend && npm start & wait"
```

## Common mistakes

- **Forgetting to restart the Shell after editing replit.nix, then wondering why new packages are not available** — undefined Fix: Type exit in the Shell to terminate it, then reopen Shell from the Tools dock. The Nix environment only reloads on Shell restart.
- **Using wrong package names in replit.nix without the pkgs prefix or with incorrect version suffixes** — undefined Fix: Search for the exact package name at search.nixos.org/packages. Package names are case-sensitive and version-specific, such as pkgs.nodejs-20_x, not pkgs.node or pkgs.nodejs.
- **Running two servers on the same port, causing one to fail with an EADDRINUSE error** — undefined Fix: Assign each server a different port (e.g., Python on 5000, Node.js on 3000) and update the [[ports]] section in .replit to map the primary port to externalPort 80.
- **Installing Python packages globally instead of per-project, causing version conflicts between Repls** — undefined Fix: Use pip install --user or virtual environments within your project. Replit isolates each Repl's Nix environment but Python packages need explicit scoping.

## Best practices

- Add language servers to replit.nix for each language to get syntax highlighting, autocompletion, and error checking in the editor
- Use separate directories for each language to prevent package manager conflicts and keep the project organized
- Pin dependency versions in lock files for every language to avoid inconsistent builds
- Run exit in Shell after editing replit.nix to reload the Nix environment with new packages
- Use the ampersand operator in the .replit run command to start multiple language processes simultaneously
- Search for exact Nix package names at search.nixos.org/packages before adding them to replit.nix
- Keep a README at the project root documenting which languages are used and how to run each component

## Frequently asked questions

### How many programming languages can I use in a single Replit project?

There is no hard limit. You can add as many language runtimes as you need through replit.nix. The practical limit is your storage quota, since each language runtime and its packages consume disk space. Most polyglot projects use two or three languages.

### Do I need a paid plan to use multiple languages in Replit?

No. The Nix environment is available on all plans including the free Starter tier. However, free plans have limited storage (about 2 GiB) and RAM, which may constrain how many runtimes you can install and run simultaneously.

### Can I get autocomplete and syntax highlighting for all languages at once?

Yes. Add the language server package for each language to your replit.nix deps array. For example, add pkgs.nodePackages.typescript-language-server for TypeScript and pkgs.python311Packages.python-lsp-server for Python. The editor detects file extensions and activates the appropriate language server.

### How do I run a Python script if my main Run button is configured for Node.js?

Open the Shell from the Tools dock and run the Python script directly with python3 yourfile.py. The Run button only executes the command defined in the .replit file, but the Shell gives you full access to all installed languages.

### Will adding multiple languages slow down my Repl?

Adding runtimes to replit.nix increases initial environment setup time but does not significantly affect runtime performance. Running multiple servers simultaneously does consume more RAM and CPU. Monitor usage via the Resources panel and consider upgrading from the free tier if you hit limits.

### Can Replit Agent build a polyglot project automatically?

Agent works best with its default stack of React, Tailwind, and ShadCN UI. You can prompt Agent to use multiple languages, but complex polyglot setups may require manual configuration of replit.nix and .replit files. Use Agent for individual components and configure the multi-language setup yourself.

### How do I share environment variables between a Python backend and Node.js frontend?

Add secrets through Tools then Secrets in the workspace. All languages access the same environment variables: Python uses os.environ or os.getenv, Node.js uses process.env, and Go uses os.Getenv. Secrets are shared across the entire Repl regardless of language.

---

Source: https://www.rapidevelopers.com/replit-tutorial/how-to-configure-replit-to-support-a-polyglot-codebase-with-multiple-programming-languages
© RapidDev — https://www.rapidevelopers.com/replit-tutorial/how-to-configure-replit-to-support-a-polyglot-codebase-with-multiple-programming-languages
