Skip to main content

Runtime Engine

Version Requirements

  • MiniApp SDK Version: >= 2.1.0 (npm package @wcm/mini-app-sdk)
  • MiniApp Runtime Engine Version: >= 3.2.0

Basic Usage

Use this to read the information provided by the SuperApp.

caution

This will read from the searchParams provided by the SuperApp on the initial URL.

Make sure to use it at the beginning of your application before you navigate away.

"use client";

import { getRuntimeEngineMetadata } from "@wcm/mini-app-sdk/runtime-engine";

// Side-effect: it reads from window.location
/** @type {{ miniappPlatformVersion?: string, otelAppId?: string, otelSessionId?: string }} */
const metadata = getRuntimeEngineMetadata();

console.log(typeof metadata.miniappPlatformVersion === "string");
console.log(typeof metadata.otelAppId === "string");
console.log(typeof metadata.otelSessionId === "string");

Reading Host Environment from User-Agent (Alternative)

export interface WovenCityAppUAEnvironment {
isWovenCityAppHost: boolean;
platform: string | null;
}

export function getWovenCityAppEnvironmentFromUA(): WovenCityAppUAEnvironment {
if (typeof navigator === 'undefined' || typeof navigator.userAgent !== 'string') {
console.warn("User-Agent detection: 'navigator.userAgent' is not available.");
return { isWovenCityAppHost: false, platform: null };
}

const ua = navigator.userAgent;
const environment: WovenCityAppUAEnvironment = {
isWovenCityAppHost: false,
platform: null,
};

if (ua.includes("WovenAppClient/SuperApp")) {
environment.isWovenCityAppHost = true;
}

const platformMatch = ua.match(/WovenAppPlatform\/(\w+)/);
if (platformMatch && platformMatch[1]) {
environment.platform = platformMatch[1].toLowerCase();
}

return environment;
}

---------------------------------------------------------------------------

import { getWovenCityAppEnvironmentFromUA } from './utils/getWovenCityAppEnvFromUA';

const uaEnv = getWovenCityAppEnvironmentFromUA();

if (uaEnv.isWovenCityAppHost) {
console.log("MiniApp is running inside Woven City App (detected via User-Agent)!");
console.log("Host OS Platform (from UA):", uaEnv.platform);
// Enable Woven City App-specific features
} else {
console.log("MiniApp is not in Woven City App (or User-Agent not modified).");
// Use fallback behavior
}