Deployment
Let's deploy the todo app to railway.app.
Prepare for Production
In order to deploy to a Node.js environment, you need to change Sveltekit's adaptor to @sveltejs/adapter-node
.
- Install
adapter-node
:
npm i @sveltejs/adapter-node --save-dev
- In
svelte.config.js
, change the adapter:
import adapter from '@sveltejs/adapter-auto'
import adapter from '@sveltejs/adapter-node'
In order to deploy the todo app to railway you'll need a railway
account. You'll also need Railway CLI installed, and you'll need to login to railway from the cli, using railway login
.
Click enter multiple times to answer all its questions with the default answer
Create a Railway
project
.From the terminal in your project folder run:
shrailway init
Select
Empty Project
Set a project name.
Once it's done add a database by running the following command:
shrailway add
Select
postgressql
as the database.Once that's done run the following command to upload the project to railway:
shrailway up
got to the
railway
project's site and click on the projectSwitch to the
settings
tabUnder
Environment
click onGenerate Domain
Copy the
generated url
, you'll need it for NEXTAUTH_URL on step 14Switch to the
variables
tabClick on
+ New Variable
, and in theVARIABLE_NAME
clickAdd Reference
and selectDATABASE_URL
Add another variable called
AUTH_SECRET
and set it to a random string, you can use an online UUID generatorAdd another variable called
NEXTAUTH_URL
and set it to thegenerated url
which was created on step 10.Wait for railway to finish deploying your changes and Click on the newly generated url to open the app in the browser and you'll see the app live in production. (it may take a few minutes to go live)
Note
If you run into trouble deploying the app to Railway, try using Railway's documentation.
That's it - our application is deployed to production, on a node js server
Love Remult? Give our repo a star.⭐