hey Documentation

Hey is a decentralized and permissionless social media app built with Lens Protocol ๐ŸŒฟ

29,427 stars TypeScript TypeScript 1 file ยท ~9,922 tokens #blockchain#crypto#dapp#graphql#hacktoberfest#lens-protocol#nextjs#react
RAW Doc

1. Project Overview & Quickstart (bigint/hey)

Hey Monorepo

Requirements

To start working with the Hey monorepo, ensure the following tools are installed:

  • Node.js (v22 or higher) - the JavaScript runtime used in this project.
  • pnpm - the package manager used throughout this repository.
  • Postgres App - the Postgres database used in development.

Installation

This repository uses pnpm workspaces to manage multiple packages within a monorepo structure.

Clone the Repository

bash
git clone [email protected]:bigint/hey.git

Install NVM and pnpm

On macOS, you can install both with Homebrew:

bash
brew install nvm pnpm

Install Node.js

Use nvm to install the required Node.js version:

bash
nvm install

Install Dependencies

From the repository root, install dependencies with pnpm:

bash
pnpm install

Set up Environment Variables

Copy the .env.example file to .env for each package or application that requires configuration:

bash
cp .env.example .env

Repeat this process for all relevant packages and applications in the monorepo.

Environment Variables

The example environment files define the following variables:

API (`apps/api/.env.example`)

  • PRIVATE_KEY - Private key used to sign Lens requests.
  • SHARED_SECRET - Token for internal API authorization.

Start the Development Server

To run the application in development mode:

bash
pnpm dev

Build

Build the application

Compile the application:

bash
pnpm build

Type-check the project

Validate the codebase with the TypeScript type checker:

bash
pnpm typecheck

Lint and Format Code

Check code quality and formatting with Biome:

bash
pnpm biome:check

Automatically fix linting and formatting issues:

bash
pnpm biome:fix

Maintenance Scripts

Convenient Node.js helpers are in the script directory:

  • node script/clean.mjs removes all node_modules, .next directories,
    pnpm-lock.yaml, and tsconfig.tsbuildinfo files.
  • node script/update-dependencies.mjs updates packages across the monorepo,
    removes old installs and commits the changes in a new branch.
  • node script/sort-package-json.mjs sorts all package.json files in the
    repository.

License

This project is released under the GNU AGPL-3.0 license. See the LICENSE file for details

๐ŸŒธ

2. Official Technical Reference & Guides (bigint/docs)

File: README.md

๐Ÿ“š Railway Documentation

Visit docs.railway.com

๐Ÿ’ก About

This is the place where all the documentation about Railway is hosted. Contributions are welcome! Change the markdown, make a pull request, and we'll merge it! Deploys will happen automagically cause the docs are hosted on Railway

๐Ÿง‘โ€๐Ÿ”ฌ Contributing

This is a NextJS project. Install Node 18, or install nvm and run nvm install and nvm use.

Develop with:

bash
pnpm i
pnpm run dev

Open localhost:3001 to see the result


File: src/docs/overview/about-railway.md


title: About Railway

Railway is a deployment platform designed to streamline the software development life-cycle, starting with instant deployments and effortless scale, extending to CI/CD integrations and built-in observability.

Deploying on Railway

Point Railway to your deployment source and let the platform handle the rest.

Flexible Deployment Sources

  • Code Repositories: With or without Dockerfiles. Railway will build an OCI compliant image based on what you provide.
  • Docker Images: Directly from Docker Hub, GitHub Container Registry, GitLab Container Registry, Microsoft Container Registry, or Quay.io. We support public and private image registries.

Hassle-Free Setup

  • Sane Defaults: Out of the box, your project is deployed with sane defaults to get you up and running as fast as possible.
  • Configuration Tuning: When you're ready, there are plenty of knobs and switches to optimize as needed.

Development Lifecycle

Software development extends far beyond code deployment. Railway's feature set is tailor-made, and continuously evolving, to provide the best developer experience we can imagine.

Configuration Management

  • Variables & Secrets: Easily manage configuration values and sensitive data with variable management tools.

Environment and Workflow

  • Environment Management: Create both static and ephemeral environments to create workflows that complement your processes.
  • Orchestration & Tooling: Build Railway into any workflow using our CLI or API.

Deployment Monitoring

  • Observability: Keep a pulse on your deployments with Railway's built-in observability tools.

Operational Model

Railway operates with an emphasis on reliability and transparency. We utilize a combination of alerting tools, internal systems, and operational procedures to maintain high uptime. Read more about product philosophy and maturity here.

Book a Demo

Looking to adopt Railway for your business? We'd love to chat! Click here to book some time with us.


File: src/docs/overview/advanced-concepts.md


title: Advanced Usage

This document outlines the more advanced concepts of Railway. It covers things like build and deploy options, networking, integrations, and observability.

Build and Deploy Options

Out of the box, many defaults are applied to builds and deployments. However, there are several ways to tailor things to your project spec.

Build Options

Railway uses Nixpacks to build and deploy your code with zero configuration. When your needs require adjustments to the defaults, we make it easy to configure things like install, build, and start commands.

Deploy Options

Deployments are created with some default options that can be overridden. Some of the options available are -

  • Replicas: By default, your deployment will go out with a single instance. With replicas, you have the ability to scale up your deployment instances.
  • Deployment Region: Deployments by default are pushed to your preferred region.
  • Scheduled Executions: Your deployment will be run once by default. If the service is intended to be a scheduled task of sorts, you can create a cron schedule.
  • App Sleep: Services are serverful and always-on. You can control this behavior, to spin down resources when they're not being used, by enabling App Sleep.

Networking

Networking can be tricky and time-consuming. We wanted to provide the best-in-class experience when it came to wiring things up. There are two basic ways we accomplish this.

Private Networking

Private Networking is a feature within Railway that will open network communication through a IPv6 wireguard mesh only accessible to your Railway services within a project.

All projects have private networking enabled and services are assigned a DNS name under the railway.internal domain. This DNS name resolves to the internal IPv6 address of the services in a project.

Railway-Provided Domains

With the click of a button, Railway will expose your service to the internet and provide you with a domain. In order to make this work, you must configure your application appropriately to ensure we know the port it is listening on. Instructions for how to do this can be found in the Public Networking guide.

Custom Domains

If you have a custom domain, you can easily add it to your Railway service.

Integration Tools

A CLI and an API are available to wire your Railway projects into any workflow.

CLI

The Railway Command Line Interface (CLI) lets you interact with your Railway project from the command line, allowing you to do things like:

  • Trigger deployments programmatically.
  • Run services locally using environment variables from your Railway project.
  • Create new Railway projects from the Terminal.
  • Deploy templates.

Public API

The Railway public API is built with GraphQL and is the same API that powers the Railway dashboard. Similar to the CLI, you can interact with your Railway project programmatically by communicating with the API.

Environments

Railway environments give you an isolated instance of all databases and services in a project. You can use them to

  • Have development environments for each team member that are identical to the production environment
  • Have separate staging and production environments

Within a service and environment, you can specify which branch to auto-deploy to that environment when a change is merged.

Observability

Any build or deployment logs emitted to standard output or standard error ( eg. console.log(...)) are captured by Railway so you can view or search for it later.

Service Logs

Logs for a specific service deployment are available from a service's view in your project, useful when debugging build or deployment failures.

Centralized Logs

Logs for all of the services in a project can be viewed together in our Observability tool within a project. This is useful for debugging more general problems that may span multiple services.


File: src/docs/overview/best-practices.md


title: Best Practices

{/*
To keep consistency we want each topic to follow the same convention -

  • What?
  • When?
  • Do X.
  • Why?
  • Image.
    */}

Railway is a highly versatile platform, offering various ways to use it, though some may be less optimal than others for most use cases. These topics aim to help you maximize both your potential and the platform's capabilities.

Use Private Networking When Possible

Private networking allows services within a project to communicate internally without the need to expose them publicly, while also providing faster communication and increased throughput.

When configuring environment variables in your service to reference domains or URLs of other services, ensure you use the private versions of these variables, such as RAILWAY_PRIVATE_DOMAIN or DATABASE_URL.

Using the private network enables communication between services within the same project without incurring service-to-service egress costs, which is particularly beneficial when interacting with databases or other internal services.

Screenshot showing the use of the RAILWAY_PRIVATE_DOMAIN variable being used via referencing.

In Railway, a project serves as a container for organizing infrastructure. It can encompass an application stack, a group of services, or even multiple service groups.

If you're about to head back to the dashboard to deploy another service like a database, there's a quicker way - look for the Create button at the top right of the Project canvas. This shortcut allows you to add new services directly to your current project.

There are a few key advantages of keeping related services within the same project -

  • Private networking - The private network is scoped to a single environment within a project, having all related services within a single project will allow you to use private networking for faster networking along with no egress fees for service-to-service communication.

  • Project clutter - Deploying a new service or database as an entire project will quickly become overwhelming and clutter your dashboard.

  • Variable management - Variables can be referenced between services within a project, reducing redundancy and making it easier to manage instead of having to manually copy variables between services.

Screenshot showing related services within a project and their connection links.

Use Reference Variables Where Applicable

Reference variables allow you to dynamically reference another variable, either from a variable set on the current service or from another service in the same project.

Rather than manually copying, pasting, and hard-coding variables like a public domain or those from another service, you can use reference variables to build them dynamically. Example VITE_BACKEND_HOST=${{Backend.RAILWAY_PUBLIC_DOMAIN}}

This approach is better than hard-coding variables, as it keeps your variable values in sync. Change your public domain? The variable updates. Change your TCP proxy? The variable updates.

Screenshot showing a reference variable used to reference the Backend's domain.


File: src/docs/overview/the-basics.md


title: The Basics

This document outlines the core concepts of Railway, providing foundational knowledge of the basic building blocks you'll work with in the platform.

In a Nutshell

  • Dashboard - Main entrypoint for all projects under your account.
  • Project - A collection of services under the same network.
  • Service - A target for a deployment source (e.g. Web Application).
  • Deployment - Built and deliverable unit of a service.
  • Volumes - Persistent storage solution for services.

Dashboard / Projects

Your main entrypoint to Railway where all your projects are shown in the order they where last opened.

Projects contain your services and environments.

Project / Project Canvas

A project represents a capsule for composing infrastructure in Railway. You can think of a project as an application stack, a service group, or even a collection of service groups.

Services within a project are automatically joined to a private network scoped to that project.

Project Settings

This page contains all the project level settings.

Some of the most commonly used project settings are -

  • Transfer Project - Transfer your project between workspaces.

  • Environments - Manage various settings regarding environments.

  • Members - Add or remove members to collaborate on your project.

  • Danger - Remove individual services or delete the entire project.

Services

A Railway service is a deployment target for your deployment source. Deployment sources can be code repositories or Docker Images. Once you create a service and choose a source, Railway will analyze the source, build a Docker image (if the source is a code repository), and deploy it to the service.

Out of the box, your service is deployed with a set of default configurations which can be overridden as needed.

Service Variables

Service Variables provide a powerful way to manage configuration and secrets across services in Railway.

You can configure variables scoped to services. These variables are specific to each service and are not shared across the project by default.

If you want to access variables from this service in another service within the same project, you need to utilize a Reference Variable.

Backups

If your service has a volume attached, this is where you can manage backups.

Backups are incremental and Copy-on-Write, we only charge for the data exclusive to them, that aren't from other snapshots or the volume itself.

From here you can perform the following actions -

  • Create a backup - Manually create a backup of the volume with a press of a button.

  • Delete a backup - Remove a backup from the list via the backup's 3-dot menu.

  • Lock a backup - Prevent a backup from being deleted via the backup's 3-dot menu.

  • Restore a backup - Click the Restore button on the backup.

  • Modify the backup schedule - Click the Edit schedule button on the header to make changes to the schedule.

Service Metrics

Service Metrics provide an essential overview of CPU, memory, and network usage for a given service.

Service Settings

This tab contains all the service level settings.

Some of the most commonly used service settings are -

  • Source - Here you can configure the deployment source, which can be either a GitHub repository with a specific branch or an image with optional credentials.

  • Networking - Generate a Railway-provided domain or add your own custom one.

  • Custom Build Command - Here you can configure a custom build command if you need to overwrite the default, only applicable with Nixpacks based builds.

  • Custom Start Command - Here, you can configure a custom start command if you need to overwrite the default.

Deployments

Deployments involve building and delivering your Service.

Volumes

Volumes are a feature that allows services on Railway to maintain persistent data.

Volume Metrics

Volume Metrics show the amount of data stored in the volume and its maximum capacity.

Volume Settings

This tab contains all the volume centric settings.

Some of the most commonly used volume settings are -

  • Mount path - The absolute path where the volume will be mounted within the deployed service.

  • Volume Size - Displays the current volume capacity and offers the option to expand it if your plan permits.

  • Wipe Volume - This action wipes all data in the volume and then redeploys the connected service.

What Next?

If you've read enough for now and are ready to get started, we suggest checking out either of these two resources next -

If you want to go deeper, click the Next button below to head to the next section - Advanced Concepts.


File: src/docs/migration/migrate-from-digitalocean.md


title: Migrate from DigitalOcean to Railway

This guide demonstrates how to migrate your WordPress site from DigitalOcean to Railway's modern cloud platform. Railway provides a streamlined deployment experience with powerful infrastructure features.

Railway offers:

  • Modern Infrastructure: High-performance cloud platform

  • Quick Setup: WordPress-ready deployment template

  • Database Support: MariaDB database capabilities

  • Integrated SSL: Automatic SSL certificate management

  • Scalable Infrastructure: Easily handle traffic spikes and growth

  • Collaborative Features: Team management, deployment protection, and role-based access

  • Priority Support: Dedicated support for Railway users

Migration Steps

Let's walk through migrating a WordPress site from DigitalOcean to Railway. This process involves backing up your existing installation, deploying WordPress on Railway and then restoring from your backup.

1. Backup your WordPress site

  • Ensure you have a backup of your existing site. Use a WordPress backup plugin of your choice to export your site data.

    Make sure this backup includes, All WordPress files, All WordPress database tables, All WordPress uploads.

  • Document your current configuration

    • Note any custom domain settings

    • Keep track of your username and password for wp-admin.

2. Deploy WordPress

  • Open the WordPress Template page

  • Click "Deploy Now" to Deploy the WordPress template.

  • Since this template doesnโ€™t require any configuration, Click "Deploy" and wait for the deployment to complete.

The template will automatically configure -

  • A MariaDB database

  • Initial WordPress setup

  • Required environment variables

  • A temporary service domain

3. Restore your site content

After the template deployment completes -

  1. Access your WordPress installation via the temporary service domain.

  2. Configure your WordPress settings

  3. Install your preferred backup plugin

  4. Restore your site content from your backup

4. Configure Domain Settings

To set up your custom domain:

  1. Open your service's Settings in Railway

  2. Navigate to the "Networking" section

  3. Add your custom domain

  4. Update your DNS records according to the instructions given.

Note: You will need to redeploy your service for WordPress to pick up the new domain.

5. Verify Migration

Before finalizing your migration -

  1. Test all WordPress functionality

  2. Verify all pages and posts are displaying correctly

  3. Check media files are properly loaded

  4. Test user authentication

  5. Verify contact forms and other interactive elements

6. Performance Optimization

Consider these optimization options for your WordPress deployment:

  • Configure caching by placing Cloudflare or a similar CDN in front of your site.

  • Optimize database performance by setting up a caching plugin.

  • Set up appropriate scaling configurations.

  • Implement CDN if needed

That's all you need to migrate your WordPress site from DigitalOcean to Railway! Need assistance? The Central Station is there to help you with any questions during your migration process.


File: src/docs/migration/migrate-from-fly.md


title: Migrate from Fly to Railway

This guide walks you through the steps needed to seamlessly migrate your app and data from Fly.io to Railway. This process is straightforward and typically takes an average of 5 - 20 minutes, depending on the size of your database and app complexity.

TL;DR: Quick Migration Steps

  • Set up new app on Railway
  • Export data from Fly.io and Import into Railway DB
  • Deploy app (including auto-migration of app config & variables)

We provide everything Fly.io offersโ€”and more! Check out our comparison guide to see the differences and make an informed choice.

Why take our word for it? Experience the Railway advantage yourselfโ€”give it a spin today!

Migration Steps

In this guide, we will migrate a Go (Gin) app with a Postgres database from Fly.io to Railway. While we are using this app as an example, the process applies to any app, making it easy to transition your projects smoothly.

Hereโ€™s the link to the app.

1. Set Up a Railway Project

Navigate to Railway's Project Creation Page.

Select the Deploy from GitHub Repo option and connect your repository. If your Railway account isnโ€™t linked to GitHub yet, youโ€™ll be prompted to do so.

2. Deploy the App

Railway auto-imports all the build configurations, deploy commands, environment variables from your Fly.io app repoโ€”no manual setup needed.

If the environment variables are missing, you can easily add them manually by following these steps:

Adding Environment Variables on Railway:

  1. Navigate to the Variables section of your service.
  2. Switch to the Raw Editor and paste the copied environment variables.
  3. Deploy the changes to apply the configuration.

Railway will deploy the Gin app as a service, as shown in the image above. You can monitor the service building and deploying in the Project Canvas.

Serverless (App Sleep) activated: In this Fly.io app, the HTTP service is configured with auto_stop_machines='stop' and auto_start_machines=true, enabling automatic stopping and restarting of machines. On Railway import, we automatically enable this setting to effortlessly optimize resource usage.

3. Database Migration

Railway supports a variety of databases, including PostgreSQL, MongoDB, MySQL, and Redis, allowing you to deploy the one that best fits your application needs. We also support many more via our templates marketplace.

If you're migrating data to Railway from Fly, you can follow these steps:

  1. Provision a new database by right clicking on the dashboard canvas and selecting Postgres.
  2. Export your data from Flyio
    • Use flyctl to connect to your Flyio Postgres instance
      • fly postgres connect -a
    • Use pg_dump to export your database
      • pg_dump -Fc --no-acl --no-owner -h localhost -p 5432 -U <your-db-username> -d <your-db-name> -f flyio_db_backup.dump
    • Use pg_restore to connect to your Railway database and restore the data from the dump.
      • pg_restore -U -h <host> -p -W -F t -d <db_name> <dump_file_name>

For detailed instructions, check out this comprehensive tutorial on migrating PostgreSQL data between services.

Once the migration is complete, update the DATABASE_URL environment variable in your Railway app to point to the new PostgreSQL database and redeploy.

4. Replicas & Multi-region deployments

In this Fly.io app, the setting min_machines_running=2 ensures that at least two instances of the service remain active. On Railway import, we automatically translate this configuration to ensure that two service instances are running without any extra setup.

If your app needs to use multi-region deployments, you can leverage Railwayโ€™s multi-region replicas.

Enable this in the Settings section of your Railway service to keep your app close to users worldwide.

Note: Multi-region replicas is currently available to Pro users.

And thatโ€™s it. Thatโ€™s all you need to migrate your app from Flyio to Railway.


File: src/docs/migration/migrate-from-heroku.md


title: Migrate from Heroku

Migrating your app from Heroku to Railway is very simple. We even support Procfiles out of the box. (Only a single process is supported for now).

All you need to do is create a project in Railway, push your code, and migrate your environment variables.

This guide will step you through the process of migrating a simple web service, using the Railway CLI.

Working Directory

In your terminal, ensure your current working directory is the same directory where your service code is located.

This is important so that as you complete the following steps, the Railway CLI is properly linked.

1. Login to Railway From the CLI

Ensure your CLI is authenticated to your Railway account:

bash
railway login

This command will prompt to open a browser to complete authentication. Once authenticated, commands executed by the Railway CLI, will be performed in the context of your Railway account.

2. Create a New Project

Now, let's create a new project:

bash
railway init

This command will prompt you to define a name for your service.

3. Deploy the Service

Once your project is created, you can push your code into the project and assign a domain.

Push the Code

Push the code into a service in Railway:

bash
railway up -d

At this point, the service is being deployed, but let's give it a domain.

Assign a Domain

The service we are migrating is a web service that should be available over the Internet, so let's assign a domain:

bash
railway domain

Now the service will be available over the Internet via the provided domain.

4. Migrate the Environment Variables

Finally, we will import the environment variables from Heroku into Railway.

Open the Project in Railway

Let's pop over to our new project in the Railway canvas.:

bash
railway open

This will open the project in your browser.

Add Heroku Variables to the Service

From the project canvas, import the Heroku variables into the service:

  • click on the service
  • click Variables tab
  • open the command palette using CMD + K or Ctrl + K.
  • search for Import variables from Heroku
  • confirm the Heroku service and hit Enter

Your Heroku variables will be imported into the service, and it will automatically redeploy.

Note: The first time you import variables from Heroku, you will be prompted to Allow Railway to connect to your Heroku account.

Conclusion

Following this guide, we have successfully migrated a simple web service from Heroku to Railway, including importing variables from Heroku into Railway.

We have completed the migration by pushing our code directly from our local machine into a service in Railway. Once you are comfortable with Railway, you may want to integrate deployments into your development workflow.

For more advanced operations, like migrating your databases from Heroku to Railway, the process will be a bit more involved, but we are happy to help work out a solution!

Need Help?

If you run into any issues, or would like help with your migrations, we would be more than happy to answer your questions on our Discord or over email at [email protected].


File: src/docs/migration/migrate-from-render.md


title: Migrate from Render to Railway

This guide walks you through the steps needed to seamlessly migrate your app and data from Render to Railway.

With features like instant deployments, CI/CD integrations, private networking, observability, and effortless scaling, Railway helps developers focus on building rather than managing infrastructure.

Railway boasts of a superior and intuitive user experience that makes deploying complex workloads easy to configure and manage.

Railway offers:

  • Broad Language and Framework Support: Deploy apps in any language or framework.
  • Flexible Deployment Options: Use GitHub, Dockerfiles, Docker images from supported registries (Docker Hub, GitHub, RedHat, GitLab, Microsoft), or local deployments via the Railway CLI.
  • Integrated Tools: Simplify environment variable management, CI/CD, observability, and service scaling.
  • Networking Features: Public and private networking.
  • Best in Class Support: Very active community on Discord and our Central Station.

..and so much more. Want to see for yourself? Try Railway for a spin today!

Migration Steps

In this guide, we will migrate a Go (Beego) app with a Postgres database from Render to Railway.

Hereโ€™s the link to the app. A simple chat app that have the options of Long polling and Web socket โ€” https://github.com/unicodeveloper/beego-WebIM

1. Set Up a Railway Project

Navigate to Railway's Project Creation Page.

Select the Deploy from GitHub Repo option and connect your repository. If your Railway account isnโ€™t linked to GitHub yet, youโ€™ll be prompted to do so.

2. Deploy the App

Railway automatically detects a render.yaml file in your repository and provisions the corresponding services, including databases, web (both public and private), crons, and workers.

If environment variables are defined in your render.yaml, Railway will import them automatically to the appropriate services. If they are not defined, you can manually migrate them by following these steps:

On Render:

  1. Go to the Environment Variables page of your service.
  2. Copy all the variables and their values.

On Railway:

  1. Open the Variables section for the relevant service.
  2. Switch to the Raw Editor and paste the copied environment variables.
  3. Deploy the changes to apply the configuration.

Railway will deploy both the Go app as a service and the database, as shown in the image above. You can monitor the service building and deploying in the Project Canvas.

3. Database Migration

Railway supports a variety of databases, including PostgreSQL, MongoDB, MySQL, and Redis, allowing you to deploy the one that best fits your application needs.

When a render.yaml file includes a databases section, Railway will automatically provision a PostgreSQL database for your app. If you're migrating data to Railway, you can follow these steps:

  1. Export your database from Render using tools like pg_dump.
  2. Import the data into Railway using psql.

For detailed instructions, check out this comprehensive tutorial on migrating PostgreSQL data between services.

Once the migration is complete, update the DATABASE_URL environment variable in your Railway app to point to the new PostgreSQL database.

4. Multi-region deployments

If your app needs to use multi-region deployments, you can leverage Railwayโ€™s multi-region replicas.

Enable this in the Settings section of your Railway service to keep your app close to users worldwide.

Note: Multi-region replicas is currently available to Pro users.

And thatโ€™s it. Thatโ€™s all you need to migrate your app from Render to Railway.


File: src/docs/migration/migrate-from-vercel.md


title: Migrate from Vercel to Railway

This guide demonstrates how to transition your application from Vercel to Railway's developer-centric platform. Whether you're running a simple static site or a complex full-stack application, Railway streamlines your deployment workflow.

With features like instant rollbacks, integrated observability, and seamless environment management, Railway empowers developers to focus on building great applications rather than managing infrastructure.

Railway offers -

  • Next.js Optimization: Built-in support for all Next.js features including ISR, SSR, and API routes

  • Zero Config Deployments: Automatic framework detection and build optimization

  • Enhanced Development Flow: Local development with production parity

  • Collaborative Features: Team management, deployment protection, and role-based access

  • Priority Support: Dedicated support for Railway users

Migration Steps

Let's walk through migrating a Next.js application to Railway. For this guide, we'll use a sample e-commerce app that showcases common Next.js features and configurations.

Deploying Your Application

To get started deploying our NextJS app, we will first make a new project.

  • Open up the dashboard โ†’ Click New Project.
  • Choose the GitHub repo option.

Railway requires a valid GitHub account to be linked. If your Railway account isn't associated with one, you will be prompted to link it.

  • Search for your GitHub project and click on it.

  • Choose either Deploy Now or Add variables.
    Deploy Now will immediately start to build and deploy your selected repo.
    Add Variables will bring you to your service and ask you to add variables, when done you will need to click the Deploy button at the top of your canvas to initiate the first deployment.
    For brevity we will choose Deploy Now.

When you click Deploy Now, Railway will create a new project for you and kick off an initial deploy after the project is created.

Once the project is created you will land on your Project Canvas.

From here Railway will automatically -

  • Detect your Next.js configuration

  • Configure the appropriate Node.js version

  • Build your application

  • Run your application

Environment Configuration

Next.js applications often rely on environment variables for API keys, database connections, and feature flags. Here's how to transfer them -

From Vercel -

  1. Visit your Vercel project settings

  2. Navigate to the Environment Variables tab

  3. Export your variables (you can copy them directly)

To Railway -

  1. Select your service in the Project Canvas

  2. Open the Variables tab

  3. Use the Raw Editor for bulk variable import

  4. Click Deploy to apply changes

Domain Configuration

Railway makes it simple to set up custom domains or use our provided domains -

  1. Open your service's Settings

  2. Navigate to the Public Networking section

  3. Choose between:

    • Generating a Railway service domain

    • Adding your custom domain

  4. Follow the DNS configuration steps if using a custom domain

Deployment Verification

Before finalizing your migration:

  1. Check your application's core functionality

  2. Verify environment variables are properly set

  3. Test dynamic routes and API endpoints

  4. Confirm image optimization is working

  5. Monitor build and runtime logs

Railway's integrated observability helps you catch any issues early in the migration process.

Local Development

Railway makes local development seamless with your production environment:

  1. Install the Railway CLI: npm i @railway/cli

  2. Run railway link to connect to your project

  3. Use railway run to start your app locally with production variables

This ensures development/production parity and helps catch issues before they reach production.

That's all it takes to move your Next.js application to Railway! Need help? Our team and community are always ready to assist.

Need more information on how we compare to Vercel? Check out our comparison page.