first commit
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
# @wrnexus/mobile
|
||||
|
||||
SSR-safe access to Capacitor plugins from WrNexus browser code.
|
||||
|
||||
```bash
|
||||
wrnexus mobile add @capacitor/camera
|
||||
```
|
||||
|
||||
```ts
|
||||
import { Camera } from "@capacitor/camera";
|
||||
import { mobile } from "@wrnexus/mobile";
|
||||
|
||||
if (mobile.isNative()) {
|
||||
mobile.registerPlugin("Camera", Camera);
|
||||
const photo = await mobile.invoke("Camera", "getPhoto", { resultType: "uri" });
|
||||
}
|
||||
```
|
||||
|
||||
`isNative()` is false and `platform()` is `web` during SSR. `plugin()` returns
|
||||
`undefined` when unavailable; `requirePlugin()` and `invoke()` throw an
|
||||
actionable `MobileUnavailableError`.
|
||||
|
||||
Import and register Capacitor packages only from browser-owned code. Do not
|
||||
import them in server routes, SSR helpers, or other Bun-only modules.
|
||||
Reference in New Issue
Block a user