@nrichardsdev/piko-sdk
v0.4.0
Published
SDK for building Piko channel apps — core utilities and React hooks
Maintainers
Readme
@piko/sdk
SDK for building Piko channel apps. Provides the core piko object and optional React hooks.
Installation
pnpm add @piko/sdk
# or
npm install @piko/sdkReact is an optional peer dependency — only needed if you import from @piko/sdk/react.
Core API
Works in any JavaScript/TypeScript project — no framework required.
import piko from "@piko/sdk";
// Close the app and return to the Piko home screen
piko.close();
// Get the active user profile
const profile = await piko.getProfile();
// { id, username, first_name, last_name, image_data }
// Read a setting (namespace with your app id)
const value = await piko.getSetting("com.yourname.app:volume");
// Write a setting
await piko.setSetting("com.yourname.app:volume", "80");React Hooks
import { useProfile, useSetting, useIsInsidePiko } from "@piko/sdk/react";
function App() {
const { profile, loading, error } = useProfile();
const { value, set } = useSetting("com.yourname.app:theme");
const insidePiko = useIsInsidePiko();
if (!insidePiko) return <p>Open this in Piko.</p>;
if (loading) return <p>Loading…</p>;
if (error) return <p>Error: {error.message}</p>;
return (
<div>
<h1>Hello, {profile?.username}</h1>
<button onClick={() => set("dark")}>Dark mode</button>
</div>
);
}Hook reference
| Hook | Returns | Description |
|------|---------|-------------|
| useProfile() | { profile, loading, error } | Active Piko profile |
| useSetting(key) | { value, loading, set } | Read/write one OS setting |
| useIsInsidePiko() | boolean | True when running inside Piko |
Notes
- The SDK only works when running inside a Piko app window.
__TAURI_INTERNALS__is injected automatically by Tauri — no extra imports needed. - Namespace all setting keys with your app's reverse-domain id to avoid collisions:
com.yourname.myapp:key. - See
docs/PIKO_APP_STORE.mdfor the full channel app guide.
