Skip to content

Getting started

SurgeMedia ships as one npm package (@surge-media/core) and one Docker image (ghcr.io/mahmoud-nb/surge-media, amd64 and arm64). Both contain the admin interface, the REST API, media delivery and image processing.

Requirement Minimum Notes
Runtime Node.js 24 or Docker The Docker image bundles Node.js.
Database SQLite (built in), PostgreSQL, MySQL or MariaDB One image for all of them.
Storage Local disk or an S3-compatible bucket AWS S3, MinIO, Cloudflare R2, Scaleway, OVHcloud…
Video processing (optional) FFmpeg 6 or later Included in the default Docker image; absent from the slim variant.

You can start on SQLite and move to PostgreSQL later: the database is selected by configuration (DATABASE_URL), not at build time.

  1. Create the folder that will hold your configuration (.env) and your data, then install the package:

    Terminal window
    mkdir media-server && cd media-server
    npm install @surge-media/core
  2. With npm 12 or later, approve the install scripts of the native modules (npm 11 and earlier run them automatically):

    Terminal window
    npm install-scripts approve better-sqlite3 @prisma/engines prisma
    npm rebuild better-sqlite3 @prisma/engines
  3. Run the interactive setup. It asks for the database (SQLite, PostgreSQL or MySQL / MariaDB), the web server port (3000, or the next free port if another application already uses it) and the public URL, applies the migrations and generates the secrets in .env. It then asks how the instance will be used (evaluation, Community production or production under a commercial license). This is only a statement: nothing is sent, and “Later” skips the question.

    Terminal window
    npx surge-media init
  4. Start the server:

    Terminal window
    npx surge-media start

    The admin, the API and media delivery answer on http://localhost:3000 (or on the port you chose). If that port is taken at startup, start stops with a clear message instead of failing silently.

  1. Open the admin at your site URL and sign in with the bootstrap account (NUXT_BOOTSTRAP_ADMIN_EMAIL / NUXT_BOOTSTRAP_ADMIN_PASSWORD). It becomes the first Admin.
  2. Remove the bootstrap variables once the account exists, and invite your team from Users.
  3. Turn on two-factor authentication from My account (any authenticator app), then require it at least for administrators in Settings › Security. In Settings › License, check the declared use of the instance (on a Docker installation, this is where you declare it).
  4. Create a project for your application, add its allowed origins (https://www.acme.com) and create its API keys: a publishable key for the browser, a secret key for your server.
  5. Upload a few media files and copy their URLs, or call the API from your application.
// SURGE_MEDIA_API_URL = https://media.example.com/api/v1
const { SURGE_MEDIA_API_URL, SURGE_MEDIA_PROJECT_ID, SURGE_MEDIA_SECRET_KEY } = process.env;
const res = await fetch(`${SURGE_MEDIA_API_URL}/projects/${SURGE_MEDIA_PROJECT_ID}/media`, {
headers: { Authorization: `Bearer ${SURGE_MEDIA_SECRET_KEY}` },
});
const { items, nextCursor } = await res.json();

The admin’s API documentation page generates this .env snippet for your project (API URL, project ID and publishable key; paste the secret key yourself).

  • Your domain and TLS: put SurgeMedia behind your reverse proxy (Nginx, Caddy, Traefik…) on a domain such as media.your-company.com, and set NUXT_SITE_URL to it. Behind a proxy, set NUXT_TRUST_PROXY so rate limits and audit logs see real client IPs.
  • A CDN in front of /m/ (optional): public media are served with immutable cache headers.
  • Backups: back up the database and the media storage together (with Docker, the /app/data volume holds both for SQLite and local storage).
  • Updates: npm install @surge-media/core@latest then npx surge-media db migrate, or pull the new Docker image (migrations run at startup).