@wrnexus/native
Cross-platform browser and Capacitor capability registry.
bun add @wrnexus/native@0.2.15Cross-platform capabilities for browsers, Capacitor WebViews, and compiled native apps.
import { native } from "@wrnexus/native";
if (native.supports("share")) await native.run("share", { title: "WRNexusJS", url: location.href });
Built-ins include camera, clipboard.write, share, geolocation, network, haptics, storage, filesystem, notifications, and device information. Browser capabilities use Web APIs; mobile capabilities use installed Capacitor plugins.
platform() returns server during SSR, browser on the web, and the Capacitor platform in a native WebView. Unsupported operations reject with NativeUnavailableError; use supports() before presenting optional UI.
Complete TypeScript API
This declaration is generated from the exact published package and lists its exported functions, classes, interfaces, and types.
import { N as NativePlatform, a as NativeCapability, b as NativeRunOptions, c as NativeTarget } from './types-CDShWg0i.js';
export { d as NativeAdapter, e as NativeBrowserRuntime } from './types-CDShWg0i.js';
export { browserCapabilities } from './browser.js';
export { mobileCapabilities } from './mobile.js';
declare class NativeUnavailableError extends Error {
constructor(message: string);
}
declare function isMobile(): boolean;
declare function platform(): NativePlatform;
declare function register<TOptions = unknown, TResult = unknown>(name: string, capability: NativeCapability<TOptions, TResult>): () => void;
declare function registered(): string[];
declare function supports(name: string, target?: NativeTarget): boolean;
declare function run<TResult = unknown>(name: string, options?: unknown, runOptions?: NativeRunOptions): Promise<TResult>;
declare function clearRegistry(): void;
declare const native: {
isMobile: typeof isMobile;
platform: typeof platform;
register: typeof register;
registered: typeof registered;
run: typeof run;
supports: typeof supports;
};
export { NativeCapability, NativePlatform, NativeRunOptions, NativeTarget, NativeUnavailableError, clearRegistry, isMobile, native, platform, register, registered, run, supports };
Examples
Copy-ready examples taken from this package's published documentation.
Example 1
import { native } from "@wrnexus/native";
if (native.supports("share")) await native.run("share", { title: "WRNexusJS", url: location.href });