Skip to main content

Configure a Repl

This guide walks you through configuring your Repl to enhance productivity and streamline your coding workflow.

Repls on Replit are highly customizable through two primary configuration files: the .replit file and the replit.nix file. These files enable you to specify a wide array of settings that affect how your Repl behaves, from the execution of code to the integration of development tools and languages.

.replit configuration file

The .replit file is useful to customize your Repl's operational behavior. It utilizes the toml configuration format, allowing you to define and modify settings easily. Here are some of the key aspects that can be configured:

Run command: Specify the command that executes when the Run button is selected, allowing for immediate and repeated testing or execution of your code.

Language Server Protocol (LSP): Enhance your coding experience by enabling LSP, which provides features like auto-completion, code navigation, and real-time linting and errors.

Environment variables: Set and manage environment variables  essential for your applications to run correctly.

Dependencies and packages: Manage package installations and configurations directly through the .replit file, ensuring your Repl has all the necessary tools ready upon startup.

replit.nix configuration file

For more granular control over the system dependencies and environments, replit.nix uses the Nix language to allow precise management of the packages and environments. This file is essential for:

Specifying system dependencies: Define exactly what software packages your Repl requires, managed through Nix, a package manager.

Creating reproducible environments: Ensure your development environment is consistent and reproducible, ideal for collaborative projects and testing across multiple systems.

To understand the replit.nix configuration to add system dependencies, refer to the System dependencies guide.

.replit file

  1. Login to Replit and navigate to your Repl. If you don't have an existing Repl, create a new Repl by selecting the + Create Repl button.
  2. Select the three-dot menu on the file tree and select Show hidden files to make the files visible.
  3. In the Config files section, select the .replit file to open it in the editor.

For Python applications, the default .replit file looks like:

entrypoint = ""
modules = ["python-3.10:v18-20230807-322e88b"]

channel = "stable-23_05"

language = "python3"

requiredFiles = [".replit", "replit.nix"]

run = ["python3", ""]
deploymentTarget = "cloudrun"

The following table provides a view of each setting within the .replit file, explaining what each configuration does and its impact on the Repl environment.

Configuration keyValue/ExampleDescription
entrypointmain.pySpecifies the main file to be executed and displayed by default when the editor is opened. You can rename the file name based on your application.
modules["python-3.10:v18-20230807-322e88b"]Defines specific versions of programming languages or other major dependencies supported by Replit.
[nix]Specifies settings for using Nix, a package manager, to manage system dependencies. Refer to Add system dependencies document for more information.
channelstable-23_05Indicates the Nix channel to use, which affects the versions of system dependencies available.
[unitTest]Configures settings related to unit testing within the Repl.
languagepython3Specifies the language used for unit testing, indicating that Python 3 is used for writing tests.
[gitHubImport]Settings that affect how projects are imported from GitHub, specifically which files must be included.
requiredFiles[".replit", "replit.nix"]Lists the files that must be present when importing the project to ensure it functions correctly.
[deployment]Contains settings for deploying the application from the Repl to a live environment.
run["python3", ""]Command executed to start the application during deployment.
deploymentTargetcloudrunSpecifies the deployment target platform for hosting the application.

Now that you have an idea of the default configurations of the .replit file use the next sections to understand how to configure basic and advanced settings for your Repl.

Configuring basic settings

This section walks through the basic settings to configure the Entrypoint and Run commands.


This is the main file of your project. It's the first file that gets executed or shown in the editor.

entrypoint = "<file-name>.py"

Replace the file-name based on your application.

Run command

The Run command in the .replit file is a key feature that determines the initial command or series of commands executed when the Run button is selected in a Replit environment. It allows you to configure how your Repl starts and manages tasks when activated. The Run command can be specified as a single string for straightforward operations or structured as an array of strings for more complex sequences requiring multiple steps. Additionally, it supports complex scenarios where multiple processes need to run concurrently.

Following are some of the most popular ways to understand and configure the Run command in a .replit file:

  • Single command: This example shows how to pass a Bash script as a String to execute a command directly in the Repl. It performs a simple echo statement to display a startup message for an application. Example: run = "echo 'Starting application...'"

  • Sequential command: This example shows how to pass an array of Bash scripts as strings to execute commands in a sequential order. If any step fails, the execution will stop.

Example: run = ["python -m venv env", "source env/bin/activate", "pip install -r requirements.txt", "python"]

  • python -m venv env creates a virtual environment in the directory named 'env'.

  • source env/bin/activate activates the virtual environment.

  • pip install -r requirements.txt installs all dependencies listed in the requirements.txt file.

  • python runs the main Python application.

  • Parallel execution: This example shows how to run multiple processes, such as a server and a client, simultaneously. This example is helpful when independent services must operate concurrently without dependencies. Example: run = "server & client & wait"

Advanced Run command techniques

The following are some advanced techniques to understand the usage of Run command.

Command chaining in the Linux environment

In a Linux environment, you can chain commands using && or ;. The && operator only runs the next command if the previous one succeeded, while ; runs the next command regardless of the previous outcome.


To set up your Python environment before running your script, first update pip and install the necessary packages using this command:

run = "python -m pip install --upgrade pip && pip install -r requirements.txt && python"
Using a Shell script

For more complex setups, when the setup commands become too long, it’s cleaner and more manageable to use a Shell script.

Step 1: Use the following code to create a Shell script in your Repl. Create a file with the file name and copy the below contents into the file.

echo "Preparing to run the application..."
pip install -r requirements.txt

Step 2: Modify the run command in the .replit file to execute the Shell script.

run = "bash"
Conditional execution

Conditional execution is useful when a program or script executes a specific code section only if specified conditions are met. While complex logic is better handled in a script, basic conditions can be managed directly in the run command.

Example Use the following command to check if a file exists and base your actions on that.

run = "test -f already_setup.txt && python || python && touch already_setup.txt && python"

This command checks if already_setup.txt exists. If it does, it runs If it doesn't, it runs, creates the file, and then runs

Including environment variables

Sometimes, you need to set environment variables right before execution to ensure they're available to your script.

Example Setting a DEBUG environment variable before running your application.

run = "export DEBUG=true && python"
Interactive mode

For languages that support interactive modes (like Python with -i), you might want the console to stay open after the script executes.


Running a Python script in interactive mode after execution.

run = "python -i"

Advanced configuration options

Explore the detailed configuration options available for your Repl. You can customize your development environment, manage run commands, integrate language services, and handle dependencies.

onBootonBootonBoot = "npm install"Command that executes when the Repl boots up.
compilecompile(No default example)Command that runs before the run command, used in compiled languages like C++.
languagelanguagelanguage = "javascript"Specifies the language during a GitHub import or when creating a Repl.
entrypointentrypointentrypoint = "index.js"Main file to run and display when opening the editor.
hiddenhiddenhidden = [".config", "package-lock.json"]Files or folders to hide by default in the side file tree.
audioaudioaudio = trueEnables system-wide audio when set to true.

Packager configuration

packagerlanguagepackager.language = "python3"Language used for package operations.
packager featuresguessImportspackager.features.guessImports = trueAutomatically guess packages to install prior to running the Repl.
packager featurespackageSearchpackager.features.packageSearch = trueEnables support for the packager when set to true.
packager featuresenabledForHostingpackager.features.enabledForHosting = falseSets whether hosting the Repl requires running a package installation.
packagerafterInstallafterInstall = "echo 'package installed'"Command executed after a new package is installed via the packager.
packagerignoredPathsignoredPaths = [".git"]Paths to ignore while attempting to guess packages.
packagerignoredPackagesignoredPackages = ["twitter", "discord"]Modules should never attempt to guess a package during installation.

Example .replit configuration for packager configuration

# Define the language for the Repl
packager.language = "python3"

# Enable features for automatic package management
guessImports = true
packageSearch = true
enabledForHosting = false

# Command to run after each package installation
packager.afterInstall = "echo 'Package installed successfully'"

# Define paths and packages that should be ignored by the package manager
packager.ignoredPaths = [".git", "node_modules"]
packager.ignoredPackages = ["twitter", "discord"]

# Additional deployment settings
run = ["python3", ""]

Deployment configuration

ConfigurationKeyValue/ExampleDescription = "npm start"Command that executes when a Deployment container starts. = "npm run build"Command that executes before running a Deployment.
deploymentignorePortsdeployment.ignorePorts = trueIf true, deployment success doesn't require an open port check.

Example .replit configuration for deployment configuration

# Specifies the main entry point for the project
entrypoint = "app.js"

# Configuration settings for deploying the application
run = "npm start"
build = "npm run build"
ignorePorts = true

Interpreter configuration has been deprecated and is no longer available in Replit. Instead, you are encouraged to use the Run commands to configure how scripts and applications are executed within your Repl environment.

Networking and extensions

portslocalPortlocalPort = 3000Port that Replit binds to an external port.
portsexternalPortexternalPort = 80Publicly accessible port linked to the localPort.
extensionisExtensionisExtension = trueSpecifies whether a Repl is a workspace extension.
extensionextensionIDextensionID = "492a5fcd-f090-4356-ace8-50755e8deb2b"Determines if a Repl is attached to a specific extension. Automatically filled when publishing a new extension.
extensionbuildCommandbuildCommand = "npm run build"Command to bundle the extension into a static directory for uploading.
extensionoutputDirectoryoutputDirectory = "./dist"Path to the static directory used to render the Extension relative to the Repl's root directory.

Example .replit configuration file for managing networking and extensions

# Networking configuration to expose your application on specific ports
localPort = 3000
externalPort = 80

# Extension settings to define and manage a workspace extension
isExtension = true
extensionID = "492a5fcd-f090-4356-ace8-50755e8deb2b"
buildCommand = "npm run build"
outputDirectory = "./dist"

Accessing Repl environment metadata


To access all environment variables:


To access a single variable (REPL_SLUG):



To access all environment variables:

import os

To access a single variable (REPL_SLUG):

import os
variable = os.environ.get('REPL_SLUG')


To access all environment variables:

use std::env;
fn main() {
    for (key, value) in env::vars() {
        println!("{}: {}", key, value);

To access a single variable (REPL_SLUG):

use std::env;
fn main() {
    let variable = env::var("REPL_SLUG").unwrap();
    println!("{}", variable);

Environment variables

Following are the environment variables accessible from within your Repl:

REPL_OWNERThe username of the owner of the Repl. If your Repl is text-based and has no webserver, REPL_OWNER will reflect the value of the current user accessing the Repl
REPLIT_DB_URLThe URL of your key-value Replit database
REPL_IDThe unique UUID string of your Repl
HOMEThe home path of your Repl
systemThe operating system running on your Repl
LANGSets the language and character encoding for your Repl, affecting how text is processed and displayed
REPL_IMAGEThe docker image that corresponds to your Repl
REPL_LANGUAGEThe programming language configured for your Repl, used to determine the runtime environment and tooling
REPL_PUBKEYSA stringified JSON object containing different public API keys
REPL_SLUGA simplified, machine-readable version of the name of the Repl, suitable for use in URLs and file names
PRYBAR_FILEThe main/entrypoint file of your Repl
REPLIT_DEV_DOMAINProvides the URL for your Repl in the Workspace. Note that this environment variable is not available in Deployments
Was this helpful?