HotupdaterHot Updater
Self Hosting (Custom)Database Adapters

Prisma

Since v0.22.0+

Build a self-hosted Hot Updater server with Prisma ORM.

Installation

Install Prisma and initialize your project.

npm install @hot-updater/server @hot-updater/aws @prisma/client@6
npm install @hot-updater/bare @hot-updater/standalone hot-updater prisma@6 --save-dev

Initialize Prisma:

npx prisma init --datasource-provider sqlite --generator-provider prisma-client-js
npx prisma generate

Keep the Prisma CLI, @prisma/client, and generated client on the same major version. The initial generate step is required before src/hotUpdater.ts imports the client.

For other databases, see Prisma's database documentation.

Setup

Create a database connection file:

src/prisma.ts
import { PrismaClient } from "@prisma/client";

export const prisma = new PrismaClient();

Hot Updater Configuration

Create the Hot Updater instance:

src/hotUpdater.ts
import { createHotUpdater } from "@hot-updater/server";
import { prismaAdapter } from "@hot-updater/server/adapters/prisma";
import { s3Storage } from "@hot-updater/aws";
import { prisma } from "./prisma";

export const hotUpdater = createHotUpdater({
  database: prismaAdapter({ prisma, provider: "sqlite" }),
  storages: [
    s3Storage({
      region: "auto",
      endpoint: process.env.R2_ENDPOINT!,
      credentials: {
        accessKeyId: process.env.R2_ACCESS_KEY_ID!,
        secretAccessKey: process.env.R2_SECRET_ACCESS_KEY!,
      },
      bucketName: process.env.R2_BUCKET_NAME!,
    }),
  ],
  basePath: "/hot-updater",
  routes: { updateCheck: true, bundles: true },
});

Protect /hot-updater/api/* with fail-closed authentication before mounting the management routes. See Security Settings.

Schema Generation

Generate the Prisma schema for Hot Updater tables.

npx hot-updater db generate src/hotUpdater.ts --yes

This command merges or replaces the Hot Updater-managed block in prisma/schema.prisma while preserving your datasource, generator, and app models.

Need to generate SQL without config? See SQL Export for standalone SQL generation with the --sql flag.

Generate Prisma Client:

npx prisma generate

Apply the schema to the development database:

npx prisma db push

For production, create and deploy a reviewed Prisma migration instead of using db push.

CLI Configuration

Configure your CLI to use this self-hosted server.

hot-updater.config.ts
import { bare } from "@hot-updater/bare";
import { s3Storage } from "@hot-updater/aws";
import { standaloneRepository } from "@hot-updater/standalone";
import { defineConfig } from "hot-updater";

const managementToken = process.env.HOT_UPDATER_AUTH_TOKEN;
if (!managementToken) {
  throw new Error("HOT_UPDATER_AUTH_TOKEN is required");
}

export default defineConfig({
  build: bare({ enableHermes: true }),
  storage: s3Storage({
    region: "auto",
    endpoint: process.env.R2_ENDPOINT!,
    credentials: {
      accessKeyId: process.env.R2_ACCESS_KEY_ID!,
      secretAccessKey: process.env.R2_SECRET_ACCESS_KEY!,
    },
    bucketName: process.env.R2_BUCKET_NAME!,
  }),
  database: standaloneRepository({
    baseUrl: "http://localhost:3000/hot-updater",
    commonHeaders: { Authorization: `Bearer ${managementToken}` },
  }),
  updateStrategy: "appVersion",
});

The storage plugin must match the storages in your server's createHotUpdater. Both use s3Storage in this example.

API Endpoints

With the route groups enabled above, the server creates these endpoints:

MethodEndpointDescription
GET/hot-updater/versionGet server version
GET/hot-updater/fingerprint/:platform/:fingerprintHash/:channel/:minBundleId/:bundleIdCheck for updates by fingerprint
GET/hot-updater/app-version/:platform/:version/:channel/:minBundleId/:bundleIdCheck for updates by app version
GET/hot-updater/api/bundlesList bundles (query: channel, platform, limit, page, after, before)
GET/hot-updater/api/bundles/:idGet bundle by ID
POST/hot-updater/api/bundlesCreate bundles
PATCH/hot-updater/api/bundles/:idUpdate a bundle
DELETE/hot-updater/api/bundles/:idDelete bundle
GET/hot-updater/api/bundles/channelsList all channels

On this page