This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.

Host

A Jetpack Compose Host component for bridging React Native and Jetpack Compose.

Android
Included in Expo Go
Recommended version:
~56.0.26

The Host component is the bridge between React Native and Jetpack Compose. Every Jetpack Compose component from @expo/ui/jetpack-compose must be wrapped in a Host to render correctly.

Installation

Terminal
- npx expo install @expo/ui
- yarn expo install @expo/ui
- pnpm expo install @expo/ui
- bun expo install @expo/ui

If you are installing this in an existing React Native app, make sure to install expo in your project.

Usage

Match contents

Use the matchContents prop to make the Host size itself to fit the content. You can pass a boolean or an object to control vertical and horizontal sizing independently.

MatchContents.tsx
import { Host, Button } from '@expo/ui/jetpack-compose'; export default function MatchContents() { return ( <Host matchContents> <Button onClick={() => console.log('Pressed')}>Sized to content</Button> </Host> ); }

The following example crashes:

MatchContentsCrash.tsx
import { Host, LazyRow, Text } from '@expo/ui/jetpack-compose'; export default function MatchContentsCrash() { return ( <Host matchContents> <LazyRow> {Array.from({ length: 5 }).map((_, i) => ( <Text key={i}>Item {i}</Text> ))} </LazyRow> </Host> ); }

Either drop matchContents on the scroll axis or give the Host a finite size on that axis via style:

MatchContentsFix.tsx
import { Host, LazyRow, Text } from '@expo/ui/jetpack-compose'; export default function MatchContentsFix() { return ( <Host matchContents={{ vertical: true }} style={{ width: '100%' }}> <LazyRow> {Array.from({ length: 5 }).map((_, i) => ( <Text key={i}>Item {i}</Text> ))} </LazyRow> </Host> ); }

With style

Apply standard React Native styles to the Host wrapper.

HostWithStyle.tsx
import { Host, Button } from '@expo/ui/jetpack-compose'; export default function HostWithStyle() { return ( <Host style={{ padding: 16, backgroundColor: '#f0f0f0', borderRadius: 8 }}> <Button onClick={() => console.log('Pressed')}>Styled host</Button> </Host> ); }

API

import { Host } from '@expo/ui/jetpack-compose';

No API data file found, sorry!