Getting Started
This guide walks you through setting up Brownie from scratch and then integrating it per platform.
Prerequisites
Before starting, ensure you have:
- Completed the React Native Brownfield Quick Start guide
- Completed the iOS Integration guide
- Completed the Android Integration guide
- React Native project with
@callstack/react-native-brownfieldinstalled - Native host app (iOS and/or Android)
- Xcode 15+ (for iOS)
- Android Studio (for Android)
Shared Setup
Step 1: Install Brownie
In your React Native app:
Step 2: Define Your Store
Create a store definition file with the .brownie.ts extension:
Import the store in your app entry point:
Step 3: Use the Store in React Native
iOS
Step 4: Build XCFrameworks
The CLI generates Swift types and builds iOS artifacts:
This produces the following in ios/.brownfield/package/build/:
YourScheme.xcframework- Your React Native modulehermesvm.xcframework- JavaScript engine (orhermes.xcframeworkfor RN < 0.82.0)ReactBrownfield.xcframework- Brownfield integrationBrownie.xcframework- Shared state library (only when using the Brownie package)BrownfieldNavigation.xcframework- Brownfield navigation integration (only when using the brownfield-navigation package)
The ios/.brownfield/build/ directory contains the build cache.
The package:ios command automatically runs brownfield codegen to generate Swift types from your .brownie.ts files.
Step 5: Add Frameworks to Native App
- Open your native Xcode project
- Drag all XCFrameworks from
ios/.brownfield/package/build/into your project - In target settings → General → Frameworks, Libraries, and Embedded Content, set all to Embed & Sign
Step 6: Register Store in Swift
In your app's entry point, register the store with initial state:
Step 7: Use the Store in SwiftUI
Android
Step 4: Add brownie configuration
Add the following block to your package.json:
Step 5: Add gson dependency
Add the gson dependency to your android module for brownfield:
Otherwise, you can also add it to your native App:
Step 6: Add AAR
The CLI generates Kotlin types and builds AAR:
Once it succeeds, publish the AAR to local maven:
The package:android command automatically runs brownfield codegen to generate Kotlin types from your .brownie.ts files.
Step 7: Register Store in Android
Register once during app startup:
Step 8: Read and Update Store from Native UI
Done!
State changes now sync automatically between React Native and native host code on both platforms.
Next Steps
- Defining Stores - Nested objects and multiple stores
- TypeScript Usage - Advanced React Native patterns
- Swift Usage - UIKit integration and API reference
- Android Usage - Kotlin setup, easy path, and advanced serializers
- XCFramework Packaging - SPM distribution and advanced options
