Skip to main content
The same bundle is served in several places. Two questions decide what your app should render: which page is this, and is there a native shell around it.

App page vs. user page

The app page is the tool; the user page is the creator’s public output from that tool (their blog, their gallery, their CV). Most apps render something quite different on each:

Shell vs. browser

A native shell (the cskn mobile, desktop or TV app) attaches a message bridge at window.cskn.bridge. A plain browser has none.
For finer detail, getPlatform() / usePlatform() return the host kind and the operating system:
In a React tree wrapped in UIProvider, useUI() gives you the same information synchronously, plus isTV and the live safe-area insets. See UIProvider.

Choosing where your app is listed

The platforms field of your app’s cskn.json lists the shells that offer your app. Each deploy publishes it.
cskn.json
The list must be non-empty and use only these four values. An app without tv never appears on a TV, so add it only once your app works with a remote. If you leave platforms out, the deploy keeps the list your app had before; a new app is then listed everywhere.

One UI per surface

A phone screen, a desktop window and a TV across the room want different layouts. appSurfaces lets your app ship a separate root component for each surface. Each one is a lazily loaded chunk, so the TV UI never downloads on a phone.
src/app/index.tsx
Call it once, at module scope, the same way you would call React.lazy.
() => Promise<{ default: ComponentType }>
required
A plain browser: the app page or a user page.
() => Promise<{ default: ComponentType }>
required
The phone and tablet shells.
() => Promise<{ default: ComponentType }>
The desktop shell. Falls back to mobile when you leave it out.
() => Promise<{ default: ComponentType }>
The TV shell. Falls back to mobile when you leave it out. The TV shell only opens apps that list tv in platforms.
ReactNode
Shown while a surface’s chunk loads. Nothing by default.
In a browser the web surface renders at once. In a shell nothing renders until the shell has said what it is, so the wrong surface is never mounted first. useSurface() returns the surface appSurfaces picked: 'web', 'mobile', 'desktop' or 'tv'. In a browser it has the answer immediately; in a shell it returns null until the bridge answers.
@cskn/ui has building blocks for the two less familiar surfaces: a desktop kit for windows with toolbars and sidebars, and a TV kit for screens driven with a remote.

What changes per surface

In a shell the user’s token arrives over the bridge. In a browser the user is signed in with a cookie on the app’s own domain. useBridgeAuth handles both. See Authentication.
Some bridge calls have a browser fallback (photo capture falls back to a file picker, notification permission falls back to Web Push), some resolve to not_available, and a few never resolve without a shell. Check the availability table before calling one from code that also runs in a browser.
Mobile and desktop shells draw a native header above your page. In a browser and on TV there is none, so you draw your own. NativeHeader from @cskn/ui picks the right one for you.
TV has no touch and no pointer, only a remote. @cskn/ui runs a spatial navigator there so arrow keys move focus between controls. See TV navigation.