Start

Your first app

create writes five files. Here is what each one does and what to change first.

manifest.json

JSON
1{
2 "id": "dev.example.my-app",
3 "name": "my-app",
4 "version": "1.0.0",
5 "lane": "community",
6 "entry": "main.tsx",
7 "icon": "icon.png",
8 "author": "Your name",
9 "repo": "https://github.com/your-name/your-app",
10 "license": "MIT"
11}

Change id before you share anything: it is reverse-DNS, immutable, and the key for the app's data. name is the home screen label and must fit in twelve characters. Every field is in Manifest.

main.tsx

TypeScript
1import { os } from '@doan-labs/duo-sdk'
2import { Nav, Page } from '@doan-labs/duo-uikit/nav.tsx'
3import { colors } from '@doan-labs/duo-uikit/tokens.stylex.ts'
4import * as stylex from '@stylexjs/stylex'
5import { useEffect } from 'react'
6import { createRoot } from 'react-dom/client'
7
8function App() {
9 useEffect(() => { requestAnimationFrame(() => os.ready()) }, [])
10 return (
11 <main {...stylex.props(styles.root)}>
12 <Nav><Page title="my-app"><ul><li>Your first Duo app</li></ul></Page></Nav>
13 </main>
14 )
15}
16
17const styles = stylex.create({
18 root: { position: 'absolute', inset: 0, display: 'flex', flexDirection: 'column', color: colors.white, backgroundColor: colors.black }
19})
20
21await os.connect()
22createRoot(document.body).render(<App />)

Two lines matter. await os.connect() runs before anything renders: it performs the handshake with the shell and fills os.view, os.owner and os.session. os.ready() after the first paint tells the shell to drop its launch cover. Everything else is React.

Colours come from the kit's tokens, never literals. The two displays have different densities and the shell tunes the palette for both; a hex value looks wrong on one of them.

Reading the fold

TypeScript
1import { useDisplay } from '@doan-labs/duo-uikit'
2
3function Layout() {
4 const view = useDisplay() // { display, placement, width, height, visible, active, focused, angle }
5 return <Grid columns={view.display === 'cover' ? 1 : 2} />
6}

display is cover or inner. width is the box you actually have, which is also the right thing to lay out against: a split half of the inner display is as narrow as the cover. angle is the hinge in degrees, live while the person folds. Displays and the fold has the rest.

Remembering something

TypeScript
1import { useKV } from '@doan-labs/duo-sdk/react'
2
3function Note() {
4 const note = useKV(os.storage, 'field-note') // { value, status, set, del }
5 return <input value={note.value ?? ''} onChange={(e) => note.set(e.target.value)} />
6}

Storage is asynchronous, string-valued and private to the app. status is hydrating, ready, saving or error. Edits made during hydration are kept, writes are serialised, and both displays see the same value. Storage explains the revisions underneath.

A complete example

Fold Compass is an independent app in about a hundred lines: it reads the hinge angle, switches between a pocket card on the cover and a board on the inner display, and keeps one field note in storage. The Developer gallery renders every kit component at both widths.

Edit this page on GitHub