@salla.sa/embedded-sdk
Communication bridge SDK for third-party apps embedded in the Salla Merchant Dashboard.
Installation
npm install @salla.sa/embedded-sdk
pnpm add @salla.sa/embedded-sdk
yarn add @salla.sa/embedded-sdk
Quick Start
import { embedded } from "@salla.sa/embedded-sdk";
async function bootstrap() {
try {
const { layout } = await embedded.init({ debug: true });
const token = embedded.auth.getToken();
if (!token) throw new Error("No token found");
const isValid = await fetch("/api/verify-token", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ token }),
}).then((res) => res.ok);
if (!isValid) throw new Error("Token is invalid");
embedded.ready();
embedded.page.setTitle("My App");
} catch (err) {
embedded.destroy();
}
}
bootstrap();
Browser Global
<script src="https://unpkg.com/@salla.sa/embedded-sdk/dist/umd/index.js"></script>
<script>
const embedded = Salla.embedded;
embedded.init({ debug: true }).then((result) => {
console.log("Layout:", result.layout);
embedded.ready();
});
</script>
API Overview
The SDK provides modules for authentication, UI components, navigation, and page management:
- Auth:
getToken(), getAppId(), refresh(), introspect()
- UI:
loading, toast, modal, confirm
- Page:
setTitle(), navigate(), redirect(), resize()
- Nav:
setAction(), onActionClick(), clearAction()
TypeScript
Full TypeScript support with exported types. See documentation for complete type reference.
Build Formats
| ESM | dist/esm/index.js |
| CommonJS | dist/cjs/index.js |
| UMD | dist/umd/index.js |
| SystemJS | dist/system/index.js |
Documentation
For complete API documentation, examples, and advanced usage, see the full documentation.