Self Hosting (Custom)Server Frameworks
Elysia
Since v0.22.0+Build a self-hosted Hot Updater server with Elysia framework.
Installation
Install Elysia and its bearer token plugin.
npm install elysia @elysiajs/bearer --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. Keep update-check routes public for React Native clients, but always protect bundle management routes before mounting the handler:
- Public:
/hot-updater/app-version/*,/hot-updater/fingerprint/* - Optional public diagnostics:
/hot-updater/version - Protected:
/hot-updater/api/*
Import the Hot Updater instance, protect /api/*, and mount it to your Elysia
app:
import { Elysia } from "elysia";
import { bearer } from "@elysiajs/bearer";
import { hotUpdater } from "./hotUpdater";
new Elysia()
.use(bearer())
.onBeforeHandle(({ bearer, request }) => {
const pathname = new URL(request.url).pathname;
if (pathname === "/hot-updater/api" || pathname.startsWith("/hot-updater/api/")) {
if (bearer !== process.env.API_KEY) {
return new Response("Unauthorized", { status: 401 });
}
}
})
.mount("/hot-updater", hotUpdater.handler)
.listen(3000);Set your API key in environment variables:
API_KEY=your-secret-api-keyConfigure the CLI to include the API key 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.API_KEY}`,
},
}),
});API Endpoints
The server automatically creates these endpoints:
| 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"
updateMode: "auto",
fallbackComponent: ({ progress, status }) => (
// ... Custom loading UI
),
onError: error => {
// ... Error handling
},
})(App);