mobile

Ship the same app to iPhone and Android, with every kitr package switched to its native version.

PlatformsClientBuilt onCapacitor

Every export of kitr/mobile, kitr/mobile/client, kitr/mobile/provider, read from the published type definitions. The guide shows them in use.

kitr/mobile

mobile

const mobile: import("@kitr/core").PlatformFactory<MobileOptions>;

iOS and Android through Capacitor. The native projects live in platforms/<name>/ios and platforms/<name>/android; the app bundle is the same client build the web platform ships.

platforms: { phone: mobile({ targets: ['ios', 'android'] }) }
kitr dev phone --target ios      # live reload on a simulator or device
kitr build phone                 # builds the web bundle and syncs it into both projects

MobileOptions

interface MobileOptions {
  /** Which native projects to create and run. Default both. */
  targets: MobileTarget[];
  /** Reverse-DNS bundle id. Default `com.example.<app>`. */
  appId?: string;
  /** Name shown on the home screen. Default the package name. */
  appName?: string;
  /** Custom URL scheme for deep links (`myapp://`). */
  scheme?: string;
  /** Dev server port the device loads from with `kitr dev <name>`. Default 3100. */
  port: number;
  /** Extra Capacitor config merged last (`plugins`, `server`...). */
  capacitor?: Record<string, unknown>;
}

MobileTarget

type MobileTarget = 'ios' | 'android';

kitr/mobile/client

capacitorPlatform

function capacitorPlatform(): Platform;

'ios' | 'android' | 'web'. Reads the global Capacitor runtime, so it is correct before any import resolves.

isCapacitor

function isCapacitor(): boolean;

True inside the iOS or Android shell.

isPluginAvailable

function isPluginAvailable(name: string): boolean;

nativeOnly

function nativeOnly<T>(fn: () => Promise<T>, fallback?: T): Promise<T | undefined>;

Run fn only inside the native shell; returns fallback on the web.

kitr/mobile/provider

preferencesDriver

function preferencesDriver(): StorageDriver;

@capacitor/preferences as a kitr storage driver: hydrated at boot, written through in the background.

mobileProvider

const mobileProvider: import("@kitr/core").KitrProvider;

Runtime provider of the mobile platform. Inside the Capacitor shell it registers the platform driver (App plugin: state, back button, deep links) and a storage driver on Preferences, which survives the OS clearing WebView storage. In a plain browser it does nothing, so the same bundle runs on the web.