Express
Since v0.22.0+Build a self-hosted Hot Updater server with Express framework.
Installation
Install Express and required dependencies.
npm install express @types/express --save-devSetup and Security
Make sure you've set up your database adapter first (see Database Adapters).
The Hot Updater handler does not include built-in authentication. Always protect bundle management routes with framework middleware before mounting the handler. Update-check routes are usually exposed for React Native clients, but that is a deployment choice:
- Update check:
/hot-updater/app-version/*,/hot-updater/fingerprint/* - Optional public diagnostics:
/hot-updater/version - Protected management API:
/hot-updater/api/*
This example uses Express middleware to protect /api/* before mounting the Hot
Updater handler:
import express from "express";
import { toNodeHandler } from "@hot-updater/server/node";
import { hotUpdater } from "./hotUpdater";
const app = express();
const handler = toNodeHandler(hotUpdater);
const authMiddleware = (req, res, next) => {
if (req.get("Authorization") !== `Bearer ${process.env.HOT_UPDATER_AUTH_TOKEN}`) {
return res.status(401).json({ error: "Unauthorized" });
}
next();
};
app.use("/hot-updater/api", authMiddleware);
app.all("/hot-updater/*", handler);
app.listen(3000);Set your auth token in environment variables:
HOT_UPDATER_AUTH_TOKEN=your-secret-auth-tokenConfigure the CLI to include the auth token when deploying bundles:
import { standaloneRepository } from "@hot-updater/standalone";
export default defineConfig({
// ...
database: standaloneRepository({
baseUrl: "http://localhost:3000/hot-updater",
commonHeaders: {
Authorization: `Bearer ${process.env.HOT_UPDATER_AUTH_TOKEN}`,
},
}),
});API Endpoints
The server automatically creates these endpoints. Bundle management endpoints
under /hot-updater/api/* are mounted only when routes.bundles is enabled:
| Method | Endpoint | Description |
|---|---|---|
| GET | /hot-updater/version | Get server version |
| GET | /hot-updater/fingerprint/:platform/:fingerprintHash/:channel/:minBundleId/:bundleId | Check for updates by fingerprint |
| GET | /hot-updater/app-version/:platform/:version/:channel/:minBundleId/:bundleId | Check for updates by app version |
| GET | /hot-updater/api/bundles | List bundles (query: channel, platform, limit, page, after, before) |
| GET | /hot-updater/api/bundles/:id | Get bundle by ID |
| POST | /hot-updater/api/bundles | Create bundles |
| PATCH | /hot-updater/api/bundles/:id | Update a bundle |
| DELETE | /hot-updater/api/bundles/:id | Delete bundle |
| GET | /hot-updater/api/bundles/channels | List all channels |
React Native Setup
Configure your React Native app to connect to this server.
import { HotUpdater } from '@hot-updater/react-native';
export default HotUpdater.wrap({
baseURL: 'http://localhost:3000/hot-updater',
updateStrategy: 'appVersion', // or "fingerprint"
fallbackComponent: ({ progress, status }) => (
// ... Custom loading UI
),
onError: error => {
// ... Error handling
},
})(App);