Learn how to configure your Replit App using .replit and replit.nix files to manage dependencies, run commands, environment variables, and deployment settings.
.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.
replit.nix
fileNix
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.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:
.replit
file, explaining what each configuration does and its impact on the Replit App environment.
Configuration key | Value/Example | Description |
---|---|---|
entrypoint | main.py | Specifies 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 Dependency Management document for more information. | |
channel | stable-23_05 | Indicates the Nix channel to use, which affects the versions of system dependencies available. |
packages | ["cowsay", "htop"] | Specifies some Nix packages to install. For more fine-grained control you can also use replit.nix . |
[unitTest] | Configures settings related to unit testing within the Replit App. | |
language | python3 | Specifies 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 Replit App to a live environment. | |
run | ["python3", "main.py"] | Command executed to start the application during deployment. |
deploymentTarget | cloudrun | Specifies the deployment target platform for hosting the application. |
.replit
file use the next sections to understand how to configure basic and advanced settings for your Replit App.
run
property, entrypoint
is the file that gets executed by the runtime.
Run
commandrun
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:
.replit
file, pressing the Run
button will display a greeting in the Console
pane:
Example: run = "echo 'Hello, Replit!'"
'
and "
, since we are explicitly passing the greeting as the first and only argument to echo
:
Example: run = ["echo", "Hello, Replit!"]
run = "python -m app & npm run start & wait"
&
, you may want a better experience distinguishing logs between services. You can add system dependencies like process-compose
to better orchestrate multiple processes.
Build
phaserun
. 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.
tsc
prior to executing your code.
Example: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]
:
Run
button, offering a way to distinguish your development environment from the terminal where your program is running.
Consider the following tally script:
Example
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.
.replit
configuration for packager configuration.replit
configuration for deployment configurationRun
commands to configure how scripts and applications are executed within your Replit App environment..replit
configuration file for managing networking and extensionsconsole.log(process.env);
To access a single variable (REPL_SLUG):
console.log(process.env.REPL_SLUG);