Migrated from Vercel to Railway.
Step 1: Choose a New Hosting Provider - Railway
Railway is a great choice for deployment due to its simplicity and flexibility. Let's proceed with setting up an account and preparing for migration. Migrating your app from Vercel to Railway is very simple. All you need to do is create a project in Railway, push your code, and migrate your envionment variables. This guide will step you through the process of migrating a simple web service, using the Railway CLI.
Step 2: Set Up Railway CLI
Make sure you have the Railway CLI installed. If not, you can install it using npm:
Step 3: Login to Railway
Log in to your Railway account using the CLI:
Step 4: Initialize Your Project on Railway
Navigate to your project directory and initialize it with Railway:
cd your-project-directory
railway init
Step 5: Create a New Project on Railway
You can create a new project on Railway directly from the CLI:
Step 6: Set Up Environment Variables
If your Vercel project uses environment variables, you'll need to set them up in Railway. You can add environment variables using the Railway Dashboard or CLI:
railway variables set VARIABLE_NAME=value
Step 8: Deploy Your Project
To deploy your project to Railway, use the following command:
Step 8: Generate a Custom Domain
Railway allows you to easily set up custom domains for your projects. Follow these steps to generate and configure a custom domain for your Railway-hosted application:
-
Open Railway Dashboard:
-
Navigate to the project you want to deploy:
- In your project dashboard, click on the "Settings" tab and then go to the "Domains" section.
-
Add a Custom Domain:
- Click on the "Add Domain" button.
- Enter your desired custom domain name (e.g.,
www.yourcustomdomain.com
).
-
Generate a Custom Domain (optional):
- Click on the "Generate Domain" button.
- Wait for Railway to generate a custom domain.
- You'll receive a notification when the link is generated, and you can use that link.
This is great when you don't need a custom domain and want clients to see your project quickly. If you need a specific custom domain, please continue to the next step.
-
Generate DNS Records:
- Railway will generate DNS records for your custom domain. These records will typically include an
A
record or a CNAME
record.
- Copy the provided DNS records.
-
Update DNS Settings with Your Domain Registrar:
- Log in to your domain registrar (e.g., GoDaddy, Namecheap, Google Domains).
- Navigate to the DNS settings for your custom domain.
- Add the DNS records provided by Railway to your domain's DNS settings.
-
Verify Domain:
- Return to the Railway dashboard and click on the "Verify" button to confirm that the DNS records are correctly set up.
- Railway will verify the domain and link it to your project.
Once verified, your custom domain will be pointing to your Railway-hosted application, and you can access it using your new domain name.