BakeNative is under active development. APIs may change.
Skip to Content
BakeNative

Native UI

The three UI packages of BakeNative - Universal (@bake-native/react/ui), SwiftUI (@bake-native/react/ui/swift-ui) and Jetpack Compose (@bake-native/react/ui/jetpack-compose) - and which one to use.

The React adapter exposes Universal and SwiftUI components. Octane uses the corresponding @bake-native/octane/ui and @bake-native/octane/ui/swift-ui imports. Jetpack Compose is planned. They follow the structure of @expo/ui: one Universal layer and one package per platform toolkit.

PackageLikePlatformsStatus
@bake-native/react/ui@expo/uiiOS, macOS, Android, web, Windowsv0.1
@bake-native/react/ui/swift-ui@expo/ui/swift-uiiOS, macOS (an HTML stand-in on the web; a build error on Android and Windows)available
@bake-native/react/ui/jetpack-compose@expo/ui/jetpack-composeAndroidcoming soon (v0.2)

When to use Native UI

Build the screen from the adapter's built-in views and supported HTML (Use built-in views first). Reach for these packages only when a part of the screen needs the platform's own UI toolkit: a SwiftUI control and its system look on iOS and macOS, for example, or Jetpack Compose on Android once it ships. Keep that part in its own component, inside a Host, so the rest of the screen stays on built-in views.

Within Native UI, start with the Universal layer (@bake-native/react/ui). It draws the platform toolkit's controls where one exists and keeps one source for every target. Use a platform package only for a control, modifier or behavior the Universal layer does not have. Examples: a SwiftUI BottomSheet with detents, a Menu, Liquid Glass button styles.

Universal's Text draws inside a Host. It is a different component from the built-in Text that @bake-native/react exports. Inside a Host, Universal's layout components (Column, Row, Spacer) arrange the controls. Outside a Host, use the built-in views.

// Universal: controls inside a Host, on every target.
import { Host, Column, Text, Switch } from '@bake-native/react/ui';

<Host>
  <Column spacing={12}>
    <Text>Settings</Text>
    <Switch label="Notifications" value={on} onValueChange={setOn} />
  </Column>
</Host>
// Platform package: only what Universal does not have, on iOS and macOS.
import { Host, Menu, Button } from '@bake-native/react/ui/swift-ui';

<Host matchContents>
  <Menu label="Sort" systemImage="arrow.up.arrow.down">
    <Button label="Name" onPress={() => setSort('name')} />
    <Button label="Date" onPress={() => setSort('date')} />
  </Menu>
</Host>

How the three relate

  • Same names. Components and props have @expo/ui's names. Universal uses the Universal names (Switch, onValueChange). A platform package uses the toolkit's names (Toggle, isOn, onIsOnChange in SwiftUI).
  • State is controlled from JS in all three. A control shows the value you pass and reports a change through its callback.
  • Host is the boundary. Each package draws what is inside its Host. A screen can hold Universal and platform hosts side by side.
  • Universal fails closed. A component or prop outside the Universal table is a build error on every target, with the alternative in the message. See Blocked and alternatives.
  • A platform package fails closed off its platform. A SwiftUI component rendered on Android or Windows is a build error (ui-swift-ui-target) that names Universal and the BAKE_TARGET branch. See SwiftUI platforms.

Compare

Universal (@bake-native/react/ui)SwiftUI (@bake-native/react/ui/swift-ui)Jetpack Compose (@bake-native/react/ui/jetpack-compose)
PlatformsiOS, macOS, Android, web, WindowsiOS, macOS. The web gets an HTML stand-in. On Android and Windows it is a build error (ui-swift-ui-target)Android
ComponentsLayout (Host, Column, Row, Spacer, Text), controls (Button, Switch, Checkbox, Slider, Picker, TextInput), Header, TabBarStacks, Form / List / Section, controls, Menu, NavigationStack, TabView, BottomSheet, GlassEffectContainer, BakeViewcoming soon
Stylingstyle, textStyle (CSS)SwiftUI modifiers (modifiers={[padding(…)]})coming soon
Unknown component or propbuild error (ui-component, ui-prop, …)not checked yet, except the Host's ignoreSafeArea (ui-swift-ui-prop)coming soon
Drawn bySwiftUI inside a Host on iOS and macOS. Elements and CSS on web and Windows, the same pixels on both. The same elements on Android until its Compose host (v0.2)SwiftUI (UIHostingController, NSHostingView)Jetpack Compose
Use it forplatform-toolkit controls with one source for every targeta system control or look Universal does not have, on Apple platformsthe same, on Android

Platform guides: Android, Windows, iOS, macOS.

On this page