Environment setup
Set up and maintain your developer environment.
Requirements
Make sure you have the following software installed:
- Node.js v22.2.0 or higher
- Git v2.28.0 or higher
You'll also need an editor for viewing and editing code (we recommend VS Code).
Install Node.js
Click here for instructions on installing Node.js
You’re going to work with TypeScript. In order for Typescript to work with Devvit, you’ll need a working Node.js environment and then the Devvit command line interface. Node.js is an open-source server environment that makes it possible to develop and run Javascript apps anywhere. Node.js lets you import and use packages (code that other people have written) into your code.
Option 1: Use node version manager (nvm)
Install or update nvm to use as a handy command-line tool for managing multiple Node.js versions on your system. This will allow you to switch between different versions easily. If you to use a different node version manager, check out these suggestions from npmjs.org.
For macOS or Linux:
- Run the following command line in your terminal to install nvm.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.6/install.sh | bash
-
Close and re-open your terminal to have nvm available.
-
Install the latest version of Node.js.
nvm install node
For Windows:
-
Download and install nvm-windows by following the instructions in the repository.
-
Restart your terminal or command prompt.
-
Install the latest version of Node.js.
nvm install node
Option 2: Use Node.js installer from nodejs.org
- Visit the official Node.js website to download the installer for your operating system (Windows, macOS, or Linux).
- Run the installer and follow the prompts to install Node.js and npm (the package manager for Node.js).
If you install Node.js this way, you may experience permissions issues when trying to run Devvit, which is documented on NPM's website. Both NPM and us here at Reddit highly encourage you to use nvm if possible. If that's not possible, here are some tips on how to fix these permissions issues. For Windows users specifically, please use a node version manager.
Check that Node.js is installed correctly by running the following commands:
node --version
npm --version
You should see the version numbers for Node.js and npm as output.
Install the Devvit CLI
To download and install the Devvit CLI, run one of the following commands:
- npm
- Yarn
- pnpm
bash $ npm install -g devvit
bash $ yarn global add devvit
bash $ pnpm add -g devvit
If you see permission errors, please read npm's official guide. Yarn depends on the same configuration as npm.
Login to Devvit
Run this to log into your Reddit account using the Devvit CLI:
$ devvit login
A Reddit authentication page will open in your browser (if the page doesn't open automatically, you can use the link in the command line output). The Devvit CLI advances automatically once the authentication process completes.
Once logged in you should be seeing something similar to this:
> Logged in as u/username
If you can't log in, make sure you are using a Reddit account that has been allowlisted for the Reddit Developer Platform.
Update the Devvit CLI
As new versions of @devvit becomes available, you can run this to update your Devvit CLI to the latest version:
- npm
- Yarn
- pnpm
bash $ npm install -g devvit
bash $ yarn global add devvit
bash $ pnpm add -g devvit
After updating the Devvit CLI, you can check the version by running:
$ devvit --version
You'll get a response like this:
> @devvit/cli/0.10.16 darwin-arm64 node-v20.2.0
To update the @devvit project dependencies to the currently installed CLI's version, run the following command from within your project directory:
$ devvit update app