Getting started

Quickstart

Six steps from an empty page to a signed-in user inside SALOPHA. The examples use plain TypeScript in the page and Express on the server; any framework works.

Last updated: November 7, 2026 · Browser SDK 1.6.0 · Bridge protocol 1.2

Before you start#

  • An HTTPS origin for your app, for example https://shop.example.com. During development http://localhost works with the simulator.
  • A server that can keep a secret (Node.js 18+ for the server SDK, or any language that can make HTTPS calls).
  • A registered app. The SALOPHA team registers it from your manifest and gives you an app id, a client id and a client secret (shown once). See Manifest and registration.

Keep these on your server only:

SALOPHA_API_BASE=https://api.salopha.com/v1
SALOPHA_APP_ID=my_shop
SALOPHA_CLIENT_ID=...
SALOPHA_CLIENT_SECRET=...   # never in the page, never in the repository

1. Add the SDK to your page#

npm install https://apps.salopha.com/sdk/v1/salopha-mini-app-sdk-1.6.0.tgz

Or without a bundler:

<script src="https://apps.salopha.com/sdk/v1/salopha-sdk.umd.min.js"></script>
<script>const app = new Salopha.SalophaMiniApp();</script>

2. Initialize#

Call initialize() before anything else. It returns the launch context: language, theme, platform, the scopes already granted, and the path to open when the app was launched from a notification, shortcut or link.

import { SalophaMiniApp, SalophaBridgeError } from "@salopha/mini-app-sdk";

const app = new SalophaMiniApp({
  // In a plain browser every call rejects with `not_in_host` unless the simulator is on. Never ship it enabled.
  devSimulator: location.hostname === "localhost",
});

const ctx = await app.initialize();
document.documentElement.lang = ctx.locale;
document.documentElement.dir = ctx.locale.startsWith("ar") ? "rtl" : "ltr";
document.documentElement.dataset.theme = ctx.theme;
app.on("themeChanged", ({ theme }) => (document.documentElement.dataset.theme = theme));

3. Sign the user in#

Ask for the sign-in code and send it to your server. The first call returns the code issued at launch; later calls return fresh one-time codes, so you can re-authenticate silently when your session expires.

const { code, launchSessionId } = await app.requestAuthCode();
const res = await fetch("/api/v1/auth/salopha", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ code, launchSessionId, nonce: app.launchNonce }),
});
if (!res.ok) throw new Error("sign-in failed");
if (ctx.entryDeepLink?.startsWith("/")) router.replace(ctx.entryDeepLink);

4. Exchange the code on your server#

The code is valid for 60 seconds and only once. Your server exchanges it with the client secret and gets the user's pairwise id and the profile fields the user agreed to share.

import express from "express";
import { PlatformClient } from "@salopha/mini-app-server-sdk";

const platform = new PlatformClient({
  baseUrl: process.env.SALOPHA_API_BASE!,
  clientId: process.env.SALOPHA_CLIENT_ID!,
  clientSecret: process.env.SALOPHA_CLIENT_SECRET!,
  appId: process.env.SALOPHA_APP_ID!,
});

const api = express();
api.use(express.json());
api.post("/api/v1/auth/salopha", async (req, res) => {
  const { code, launchSessionId, nonce } = req.body;
  const r = await platform.exchangeCode({ code, launchSessionId, nonce });
  // r.sub: stable per-app user id. r.profile: displayName, phone?, avatarUrl?, locale?, city? (by consent).
  const user = await users.upsert({ sub: r.sub, name: r.profile?.displayName });
  res.json({ token: issueSession(user) }); // your own session (JWT, cookie...)
});

Store sub as your user key. Never key users by phone number.

5. Tell the host you are ready#

SALOPHA shows your app's splash (logo and colours) from the tap until the page is ready. SDK 1.1 and later call ready() for you once initialize() has resolved and the window load event fired. To keep the splash until your first screen has data:

const app = new SalophaMiniApp({ autoReady: false });
await app.initialize();
await loadFirstScreen();
await app.ready();

6. Test, then publish#

  • In a browser: devSimulator: true answers every bridge method with mock data and asks for consent with window.confirm. See the simulator.
  • Inside SALOPHA: once the app is registered with your HTTPS origin in allowedOrigins, open it from the Services tab and check the splash, sign-in, a notification and a shared link.
  • Publish: every user-visible change ships as a new release version, published from the admin console. Run through the go-live checklist first.
Next. Ask for more data with scopes, notify users from your server, and add chat actions so people can use your app from any conversation.