Skip to main content
Replit Apps are configured with two files: the .replit and replit.nix. They affect how your Replit App behaves, from code execution to development tools and languages. These configuration files are hidden by default. Show them in your Replit App by selecting “Show hidden files” from the filetree menu.
image

replit.nix file

Replit uses Nix to manage packages and environments. The replit.nix file is used for: Specifying system dependencies: Define exactly what software packages your Replit App 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. You can manage Nix packages visually through the Dependencies tool. Learn more in the System Dependencies guide. To configure packages with the replit.nix file, you can list Nix packages in the deps array, prefixed with pkgs.. Any changes will be synced after your shell is reloaded.

.replit file

The .replit file controls your Replit App’s behavior. It uses the toml configuration format. Here are some of the key aspects that can be configured: Run command: Specify the command that executes when the Run button is selected. Each template has a default run command to allow code execution immediately. For more customized and complex apps, use Workflows. Language Server Protocol (LSP): Provides features like auto-complete, code navigation, code highlighting, 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 Replit App has all the necessary tools ready upon startup. You can manage dependencies visually through the Dependencies tool. Learn more in the System Modules guide. For Python applications, the default .replit file looks like:
The following table provides a view of each setting within the .replit file, explaining what each configuration does and its impact on the Replit App environment. 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 Replit App.

Configuring basic settings

Entrypoint

This is the main file of your project. If you do not define a run property, entrypoint is the file that gets executed by the runtime.

Run command

The run property 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. The Run command can be specified either as a string representing the command to execute, or an array of strings representing the command and individual arguments to that command. Some common ways to configure the Run command:
  • Single command: This example shows how to pass single command to execute directly in the Replit App. With this in your .replit file, pressing the Run button will display a greeting in the Console pane: Example: run = "echo 'Hello, Replit!'"
  • Explicit arguments: In some situations it may be beneficial to be more explicit, avoiding the need for parsing quotes or shell interpolation rules. You can rewrite the above example to separate the arguments. Note, you no longer need both ' and ", since you are explicitly passing the greeting as the first and only argument to echo: Example: run = ["echo", "Hello, Replit!"]
  • Multiple commands: This example shows how to run multiple processes, such as a frontend and a backend, simultaneously. This could be useful if developing a python backend and a typescript frontend, where each server binds to a different port: Example: run = "python -m app & npm run start & wait"

Process management

While multiple commands can be simultaneously run with &, you may want a better experience distinguishing logs between services. You can add system dependencies like process-compose to better orchestrate multiple processes.

Build phase

For some languages or runtimes, there is a separate compilation phase before code can be run. This covers both compiled languages like TypeScript, Golang, or Java, or offering a parameter you can use to reset your environment, data, or configuration before the next run is invoked.
  • Compiling: In a TypeScript repository, you may find yourself needing to run tsc prior to executing your code. Example:

Including environment variables

To supply environment variables to your service before execution, you can expand the run property into a table. This is a more involved change, and likely requires moving where your run = "..." property is located inside your .replit file. The following diff shows supplying the command by way of [run]’s args, as well as the variable NAME supplied in [run.env]:

Interactivity

Interactive programs can also be launched by way of the Run button, offering a way to distinguish your development environment from the terminal where your program is running. Consider the following tally script: Example

Advanced configuration options

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

Notes about System-Wide Audio

When setting audio = true in your .replit file, you may need to run kill 1 in a shell to force the new setting to take effect. When running a graphical application, you will see a pair of headphones with a checkbox in the lower right of the Output pane. Due to browser restrictions, this will need to be enabled every time you refresh.

Packager configuration

Example .replit configuration for packager configuration

Deployment configuration

Example .replit configuration for deployment configuration

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 Replit App environment.

Port configuration

Example .replit configuration file for managing ports

Accessing Replit App environment metadata

Node.js

To access all environment variables: console.log(process.env); To access a single variable (REPL_SLUG): console.log(process.env.REPL_SLUG);

Python

To access all environment variables:
To access a single variable (REPL_SLUG):

Rust

To access all environment variables:
To access a single variable (REPL_SLUG):

Environment variables

Following are the environment variables accessible from within your Replit App: