Create project Run the init command to start the setup process:
Configure flexnative.json You will be asked a few questions to configure flexnative.json
:
Where is your tsconfig.json? (tsconfig.json)
What path should map to '@/*'? (./src/*)
Which theme do you want to use for now? (default)
After the command is finished, you will see a message like this:
β
Created/updated flexnative.json
β
Created: constants/colors.ts
β
Created: hooks/theme/use-color-scheme.ts
β
Created: theme/theme-colors.ts
π Init finished!
Configure the root layout In your RootLayout
, integrate the theme colors:
import { SafeAreaView, KeyboardAvoidingView, Platform } from "react-native" ;
import { getThemeColors } from "@/theme/theme-colors" ;
import { Stack } from "expo-router" ;
export default function RootLayout () {
const colors = getThemeColors ();
return (
< SafeAreaView
style ={ {
flex: 1 ,
backgroundColor: colors[ "background" ],
} }
>
< KeyboardAvoidingView
style ={ { flex: 1 } }
behavior ={ Platform. OS === "ios" ? "padding" : "height" }
keyboardVerticalOffset ={ Platform. OS === "ios" ? 0 : 0 }
>
< Stack
screenOptions ={ {
headerShown: false ,
contentStyle: {
backgroundColor: colors[ "background" ],
},
} }
>
< Stack.Screen name = "(with-tabs)" />
</ Stack >
</ KeyboardAvoidingView >
</ SafeAreaView >
);
}
Handle nested layouts (if you have them) If you use nested layouts (e.g., Tabs), ensure you define the background styles explicitly. Defining explicit styles for nested layouts ensures a consistent look across all screens:
app/(with-tabs)/_layout.tsx import { Tabs } from "expo-router" ;
import { getThemeColors } from "@/theme/theme-colors" ;
export default function Layout () {
const colors = getThemeColors ();
return (
< Tabs
screenOptions ={ {
sceneStyle: {
backgroundColor: colors[ 'background' ]
},
tabBarStyle: {
backgroundColor: colors[ 'background' ],
borderTopColor: colors[ 'muted' ]
}
} }
/>
); }
That's it You can now start adding components to your project.
npx flexnative-cli add "https://registry.flexnative.com/c/button.json"
The command above will add the Button component to your project. You can then import it like this:
import { Button } from '@/components/ui/button' ;
< Button variant = "default" label = "Default" />