๐ How to Set Up Strapi Locally and Deploy to Railway (The Easy Way)
Want to build and deploy your own Strapi CMS without touching Docker or overcomplicating things? Here is how you can go from local development to a live app on Railway with no one-click templates needed.
๐ Quick Note: Strapi Cloud vs Railway
Strapi offers their own free tier cloud hosting:
๐ https://strapi.io/pricing-cloud
But many developers prefer Railway for full control over:
- your Strapi app
- your data
- your file system
- your deployments
- your database choices
If that sounds like your style, try Railway here:
๐ https://railway.com?referralCode=ps81C1
1. ๐งโ๐ป Set Up Strapi on Your Local Machine
Step 1: Install Strapi CLI
npm install -g create-strapi-app
Step 2: Create Your Project
npx create-strapi-app@latest my-strapi-project --quickstart
This spins up a new Strapi app and launches it at:
http://localhost:1337
๐ก Tip: When prompted to create an admin user in the browser, go ahead and do that now.
Step 3: Test and Tweak
Add your content types, explore the admin panel, and make sure everything works as expected.
When finished, stop the server:
ctrl + c
2. ๐งณ Prepare Your Project for Railway
Step 1: Add Environment Configs
Create a .env file in your project root:
DATABASE_CLIENT=sqlite
NODE_ENV=production
PORT=1337
APP_KEYS=someLongAppKey1,someLongAppKey2
API_TOKEN_SALT=randomStringHere
ADMIN_JWT_SECRET=randomSecretHere
JWT_SECRET=anotherSecretHere
๐ Use https://randomkeygen.com to generate secure values.
Step 2: Update package.json Scripts
Ensure your scripts section includes:
"scripts": {
"develop": "strapi develop",
"start": "strapi start",
"build": "strapi build",
"strapi": "strapi"
}
Step 3: Push to GitHub
git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin https://github.com/your-username/your-repo.git
git push -u origin main
3. ๐ข Deploy to Railway
Step 1: Connect Your GitHub Repo
- Go to Railway: https://railway.com?referralCode=ps81C1
- Create a new project
- Select Deploy from GitHub Repo
- Choose your Strapi repository
Step 2: Set Environment Variables
Go to Railwayโs Variables tab and add the same values you put in your .env file.
โ ๏ธ Your app will not deploy correctly without these secrets.
Step 3: Trigger the Deployment
Railway detects it is a Node.js project and automatically runs:
npm run buildnpm start
Once deployed, you will get a live URL in the Deployments tab ๐
4. โ Final Touches
- ๐ฆ Prefer PostgreSQL over SQLite? Add Railwayโs PostgreSQL plugin and update your
.env. - โ๏ธ Want persistent media uploads? Use a Strapi upload provider such as S3 or Cloudinary: https://docs-v4.strapi.io/dev-docs/plugins/upload/
- ๐ If exposing APIs, configure CORS plus roles and permissions.
๐ฏ Thatโs It
You have now built and deployed a Strapi CMS, fully customized and not locked into any presets.
Try Railway:
๐ https://railway.com?referralCode=ps81C1
Curious about Strapi Cloud? Explore it here:
๐ https://strapi.io/pricing-cloud
Top comments (0)