Self-hosting SvelteKit app - the easy way

Published: (January 3, 2026 at 08:55 AM EST)
6 min read
Source: Dev.to

Source: Dev.to

Deploying a SvelteKit App on a VPS with Dokploy

This is a follow‑up to my post “Why We Left Vercel and Switched to Self‑Hosting.”

SvelteKit is great, and most tutorials point you at Vercel because it’s the most convenient way to deploy a SvelteKit app. However, Vercel’s pricing can become unpredictable as traffic grows.

A cheaper, more predictable alternative is to rent a virtual private server (VPS). You can get a decent Linux VPS for under $5 / month from providers such as:

  • Hetzner
  • Hostinger
  • DigitalOcean
  • Vultr
  • OVHcloud

You’ll need to set up the server yourself, but the process is straightforward.

1. Get a VPS

  1. Choose a provider and select a location + OS (Ubuntu is a good default).
  2. Do not use SSH‑key authentication for the first login – use username/password instead.
  3. After the purchase you’ll receive:
    • An IP address
    • A password (the username is usually root for Linux or Administrator for Windows)

2. Connect to Your VPS

Open a terminal on your local machine and run:

ssh root@123.45.67.89   # replace with your VPS IP

You’ll be prompted for the password (it won’t echo). The first time you connect you’ll see a fingerprint warning:

The authenticity of host '123.45.67.89 (123.45.67.89)' can't be established.
ED25519 key fingerprint is SHA256:NTw36MQjDxsHlxC/Xso5yKMlKJu93uYknRx2LEaqk7I.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes

Type yes and press Enter. The fingerprint is stored locally, so you won’t see this prompt again.

You are now logged into the VPS and can run commands directly on it.

3. Install Dokploy

Dokploy (or alternatives like Coolify or CapRover) makes it easy to run Docker‑based apps. I’ll use Dokploy because it’s simple and well‑documented.

curl -sSL https://dokploy.com/install.sh | sh

If the script succeeds you’ll get a URL (e.g. http://your-vps-ip:3000) where the Dokploy UI is available. Open that link in a browser, register with an email and password, and you’re ready to go.

4. Point a Domain at Dokploy

  1. In your domain registrar’s DNS settings, create an A record that points dokployadmin.YOURDOMAIN to your VPS IP.
  2. Wait a few minutes for DNS propagation.

In the Dokploy UI go to Settings → Web Server → Server Domain and set:

Domain: dokployadmin.YOURDOMAIN   # e.g. dokployadmin.superapp.com

Dokploy will automatically obtain a Let’s Encrypt certificate, so after a minute you can reach the UI at:

https://dokployadmin.YOURDOMAIN

Tip: Change the Dokploy password (Account → Profile) now that HTTPS is active.

5. Prepare Your SvelteKit App for Docker

Dokploy supports several build types; we’ll use a Dockerfile.

a. Add Dockerfile and .dockerignore

Dockerfile

# ---------- Build stage ----------
FROM node:22-alpine AS build

WORKDIR /app

COPY package.json package-lock.json ./
RUN npm ci

COPY . .
RUN npm run build

# ---------- Run stage ----------
FROM node:22-alpine AS run

WORKDIR /app

ENV NODE_ENV=production
ENV PORT=3000

COPY --from=build /app/package.json ./
COPY --from=build /app/build ./build
COPY --from=build /app/node_modules ./node_modules

EXPOSE 3000

CMD ["node", "build"]

.dockerignore

# Git files
.git
.gitignore
.gitattributes

# Documentation
README.md

# IDE / editor files
.vscode
.editorconfig

# SvelteKit build/cache
.svelte-kit

# Node modules (installed in Docker)
node_modules

# Local build output (Docker builds from source)
build

# Config files not needed in container
.prettierrc
.eslintrc.cjs
.graphqlrc
.npmrc

# Environment files (secrets)
**/.env

b. Install the Node adapter

npm install @sveltejs/adapter-node

c. Update svelte.config.js

import adapter from '@sveltejs/adapter-node';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';

const config = {
  preprocess: vitePreprocess(),
  kit: {
    adapter: adapter(),
  },
};

export default config;

d. Handle private environment variables

Only variables without the PUBLIC_ prefix are private. Access them via $env/dynamic/private:

import { env } from '$env/dynamic/private';

// Example usage
const secret = env.PRIVATE_PASSWORD;   // or any other PRIVATE_ variable

Make sure the .env file (or your CI secrets) contains all required private variables.

e. Commit & push

git add Dockerfile .dockerignore svelte.config.js
git commit -m "Add Docker support for Dokploy"
git push origin main   # or your default branch

6. Create a Project & Service in Dokploy

  1. Home → Projects → +Create Project – give it a name and description.
  2. Inside the project, click + Create Service → Application.
  3. Fill in the fields:
    • Repository URL – your GitHub (or GitLab/Bitbucket) repo URL.
    • Branch – usually main or master.
    • Build type – select Dockerfile.
    • Port3000 (as defined in the Dockerfile).
  4. Save the service. Dokploy will clone the repo, build the Docker image, and start the container.

7. Expose Your SvelteKit App

After the service is running, go to Settings → Web Server → Server Domain (or the service’s “Domain” tab) and set a sub‑domain for the app, e.g.:

app.YOURDOMAIN   # e.g. app.superapp.com

Dokploy will automatically provision an HTTPS certificate for this domain.

Visit https://app.YOURDOMAIN – you should see your SvelteKit app live.

Recap

StepWhat you did
1️⃣Rent a cheap Linux VPS (Ubuntu)
2️⃣SSH into the server (ssh root@IP)
3️⃣Install Dokploy (`curl …
4️⃣Point a domain (dokployadmin.YOURDOMAIN) to the VPS and configure it in Dokploy
5️⃣Add a Dockerfile + .dockerignore, install @sveltejs/adapter-node, and adjust svelte.config.js
6️⃣Push the changes to Git, create a Dokploy project & service using the Dockerfile build
7️⃣Assign a domain to the service and enjoy HTTPS‑served SvelteKit

You now have a fully self‑hosted, cost‑predictable SvelteKit deployment without relying on Vercel’s pricing model. Happy coding!

Deploy a SvelteKit App with Dokploy

Below is a cleaned‑up, step‑by‑step guide that preserves the original instructions while giving the content proper Markdown structure.

1. Create the Application

  1. Enter your application name, app name, and description.
  2. Click Create – an empty application is created.
  3. Click on the newly created app to open its details.

2. Connect Your GitHub Repository

  1. In the Provider section, select GitHub.
  2. Follow the flow to connect your GitHub account.
  3. After the account is added, click the Install icon.
  4. Choose the repository you want to deploy to Dokploy.

3. Configure the Service

  • Select your GitHub account, repository, and branch.
  • (Optional) Enable Trigger for automatic redeployment on pushes.
  • If you prefer a manual webhook, copy the Webhook URL from Dokploy → Deployments and paste it into GitHub → Settings → Webhooks.
  • Click Save.

4. Set the Build Type

  1. Scroll to Build Type.

  2. Choose Dockerfile.

  3. In the Dockerfile input field, type:

    ./Dockerfile
  4. Click Save.

5. Add a Custom Domain

  1. Go to Domains → Add Domain.

  2. Fill in the host field, e.g.:

    www.[YOURDOMAINNAME]   # e.g. www.superapp.com
  3. Save the domain.

6. Set Environment Variables

  1. Navigate to Environment.

  2. Under Environment Settings and Build‑time Secrets, add every variable used by your SvelteKit app (the same ones from your .env file). Example:

    PUBLIC_URL = https://yourdomain.com
    PRIVATE_PASSWORD = FDR885dafdafdsafda.........
  3. Save the changes.

7. Deploy the Application

  1. Go to the General section.
  2. Click the Deploy button.

Your SvelteKit app should now be live!

Additional Resources

  • Dokploy Video Tutorials – The homepage lists several detailed videos (not SvelteKit‑specific).

  • What Else Can Dokploy Do?

    • Install databases such as PostgreSQL, MySQL, MariaDB, MongoDB, or Redis.
    • Choose from >70 pre‑configured templates (Supabase, n8n, Java Runtime, PocketBase, etc.).

Happy deploying!

Back to Blog

Related posts

Read more »

My Experimental Portfolio is Live! 🚀

!Saurabh Kumarhttps://media2.dev.to/dynamic/image/width=50,height=50,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%...