Railway is a deployment platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.
We will get you up and running quickly by covering the following three steps:
- Creating a project from a template
- Developing the project locally
- Deploying to the cloud
First, to deploy the NextJS Prisma template, we will make a new project.
Railway offers a Command Palette that exposes all actions that one can do on the platform. We will use this menu to create our project.
Press the Command + K key combination and type "New Project".
Under the list of options in the menu, select "Deploy Template".
Deploy the Next JS Prisma Template
Railway offers 50+ templates ranging from blogs to self-hosted apps. Use the search bar at the top right and type
NextJS Prisma template to deploy it.
Railway requires that you have a valid GitHub account linked to deploy a template. If there is no account associated with your Railway account, you will be prompted to link an account.
Let's go with the default settings in the Deploy menu and click the "deploy" button.
When you click deploy, Railway will create a repo using the
NextJS Prisma template as the source on your linked GitHub account and kick off an initial deploy after the project is created.
Once the project is created you will land on your project dashboard.
You should see a Postgres plugin in the project dashboard, we use this to persist our To-Dos in the app.
Congrats! After the initial deployment finalizes, your web server is nearly ready to go. All you now need to do is just to Generate a Domain
After doing this, click on the deployment and navigate to your deployment to see the app live. In the next step, we will personalize your new web app.
So far Railway spun up a Postgres instance and a web server providing all the needed variables on deploy. We will connect to that very same Postgres instance locally to help us develop our app.
Let's begin by cloning the repo you created on your machine.
(Tip: you can navigate directly to the Project's repo from the deployment pane using the Command Palette.)
Install and Link the CLI
The Railway CLI connects your code to your infrastructure.
(Note: Brew works best on M1 Macs.)
Log in to your account by running the login command:
Then, when you are in your project's directory, link your repo to the template project with the following command:
railway link makes the Railway CLI aware of project variables when you run development commands locally. Something we will explore in depth in the next section.
Run and Develop Your App
When developing locally, it's likely that you'll need environment variables to store sensitive connection strings. Railway provides those variables whenever you run the following command:
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 by running the following command:
Our code needs the Postgres DB connection variables to persist the To-Dos locally,
railway run makes that possible.
Start the development server with the environment variables sourced by Railway through the CLI like so:
Let's make a tiny change to our application to see if everything is working.
src/pages/index.tsx in a text editor of your choice and change line 79 of the
<h1> JSX tag to the following string.
If you are running the dev server locally, you'll see the change. Feel free to change anything within the project as well! We can't stop you.
Once you are done, save the file. If you're in a Git repository, you may also commit and push to your remote Git repository. In the next step, we will show you how easy it is to deploy your changes.
To deploy your current directory, run the following command. Make sure you are in the project root directory in your terminal.
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 on a GitHub repo like a template, auto deploys are automatically enabled. Commits on the main branch 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. If you added To-Dos while developing locally, you should see them on your deployment live. In a proper project, you would enable multiple environments to isolate your production environment.
This is only the beginning, there are many features we haven't yet covered in this guide that we will touch on in the next step.
Railway aims to be the simplest way to develop, deploy, and diagnose issues with your application. Railway offers additional features that are worth exploring:
- Railway lets you create parallel, identical environments for PRs/testing.
- Railway lets you run as much (or as little) compute as you'd like with its 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.
- Railway supports projects of any size, you can deploy additional services to the same project or deploy subdirectories of a monorepo.
As your Project scales, Railway scales with you by supporting 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