Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.
The following guide will get you up and running quickly by covering the following 3 steps.
- Creating a project from a starter.
- Developing the project locally.
- Deploying to the cloud.
You will need Node or Homebrew installed to install the Railway CLI.
Create a Project
Create a new Railway project by visiting dev.new. We will deploy a starter to show how quick you can get up and running on Railway.
Press Command + K and select "Deploy Starter"
You will be prompted with a grid of starters. Railway supports a number of languages out of the box and can provision infrastructure like databases to extend your applications. These are what we call Plugins, they can be added and removed at any time.
In the starter selection grid, select
This will create a repo using the starter as a base on your linked GitHub account. If you don't have a linked GitHub account, you will be prompted to link an account to deploy.
Once the project is created you will land on your project dashboard.
Install and Link the CLI
Clone the repo you created locally on your machine. (Tip: you can navigate directly to the Project's repo from the deployment pane.)
The Railway CLI allows you to connect your code to your infrastructure.
After installing it, and signing in. If you are in your project's directory, you can link your project to a directory with
projectId is available on your project dashboard under the Setup page. If you were logged in to
the Railway dashboard when you created your project, you can run
before init which will allow you to select from all your existing projects.
When developing locally, you can connect to your infrastructure by running your code with
We will inject all the environment variables inside your current Railway environment. This allows your application to take advantage of your plugins and any environment variables you wish to set up.
Locally install the project dependencies. Then, lets make a tiny change to our application. Open
src/pages/index.tsx in a text editor of your choice and change line 76 of the
<h1> JSX tag to
My Todos, for those running the dev server locally should see the change.
Save the file, now we are ready to deploy.
To deploy your current directory, run
This will create a deployment using the current project and environment. Click the returned link to see the build and deploy logs.
For projects based off of a GitHub repo like a starter, auto deploys are automatically enabled. Commits on main trigger a redeploy, you can also enable ephemeral deploy environments for PRs made in GitHub Repos.
After your deployment completes: you can see your new deployment live at the deployment's URL. At this stage you can even add a custom domain to the Project and enable multiple environments to isolate your production environment.
Railway aims to be the simplest way to develop, deploy, and diagnose issues with your application. There's additional features we haven't covered in this guide but are worth exploring.
- Railway automagically manages your environment variables for plugins. Add Postgres -> that project instantly gets access.
- Railway let's you create parallel, identical environments for PRs/testing
- Railway let's you run as much (or as little) compute as you'd like with it's usage based pricing and a metrics dashboard included in every project.
- Adding team members to your projects is as easy as sending them an invite link.
As your Project scales, Railway scales with you by supporting with multiple members per Project, Teams, and Autoscaling- leaving you to focus on what matters: your code.
Join the Community
Chat with Railway members, ask questions, and hang out on our community Discord with fellow builders! We'd love to have you.
Edit this file on GitHub