Skip to main content

React Native

Set up Vortex Native in a new React Native Community CLI app. For an existing app, follow Quick Start.

Create the app

Create an app with the Community CLI. Replace AcmeApp with your app name.

bunx @react-native-community/cli@latest init AcmeApp --pm bun

Answer yes when the CLI asks to install CocoaPods; iOS builds need them. New apps include react-native-safe-area-context, which the screen surface below uses.

Install the packages

Vortex packages are private and available by invitation. Complete the package access prerequisites before installing.

bun add @vortexlabs/vortex-native @vortexlabs/vortex-themes

Vortex Native has no native code, so it doesn't add pods or Gradle dependencies.

Generate your theme

Create vortex-native.config.ts at your project root. Replace acme with your theme name; an empty definition inherits Vortex's defaults.

vortex-native.config.ts
import type { VortexNativeThemeConfig } from "@vortexlabs/vortex-themes";

const config: VortexNativeThemeConfig = {
  themes: {
    acme: {},
  },
};

export default config;

Add a script to your existing package.json. The CLI is included in @vortexlabs/vortex-themes.

package.json
"scripts": {
  "build:theme": "vortex-themes theming --platform native --output ./src/themes"
}
bun run build:theme

This creates src/themes/acme/theme.native.ts. Run the script again after changing vortex-native.config.ts or upgrading Vortex Native or Vortex Themes.

Add the provider

Replace the template's App.tsx. VortexProvider applies the theme, and the surface paints the theme background behind the status bar and keeps content inside the safe area:

App.tsx
import { useTheme, VortexProvider } from "@vortexlabs/vortex-native";
import type { ReactNode } from "react";
import { StatusBar, View } from "react-native";
import { SafeAreaProvider, useSafeAreaInsets } from "react-native-safe-area-context";
import acmeTheme from "./src/themes/acme/theme.native";
import HomeScreen from "./src/HomeScreen";

const AppSurface = ({ children }: { children: ReactNode }) => {
  const { theme, colorMode } = useTheme();
  const insets = useSafeAreaInsets();

  return (
    <View
      style={{
        flex: 1,
        backgroundColor: theme.color[colorMode].backgroundDefault,
        paddingTop: insets.top,
        paddingBottom: insets.bottom,
      }}
    >
      <StatusBar barStyle={colorMode === "dark" ? "light-content" : "dark-content"} />
      {children}
    </View>
  );
};

const App = () => (
  <SafeAreaProvider>
    <VortexProvider theme={acmeTheme} defaultColorMode="system">
      <AppSurface>
        <HomeScreen />
      </AppSurface>
    </VortexProvider>
  </SafeAreaProvider>
);

export default App;

defaultColorMode="system" follows the device's light or dark setting.

Run the app

src/HomeScreen.tsx
import { Stack, Text } from "@vortexlabs/vortex-native";

const HomeScreen = () => (
  <Stack gap={2} padding={4}>
    <Text size="heading-xl">Hello Vortex</Text>
    <Text color="subtle">Built with Vortex Native.</Text>
  </Stack>
);

export default HomeScreen;
bun run ios

Use bun run android for Android. If you skipped CocoaPods when creating the app, install them before the first iOS run:

bundle install && cd ios && bundle exec pod install

Fonts

Vortex Native doesn't load font files. The Vortex theme uses Hellix for headings and Inter for body text; until your app bundles fonts registered under those family names, text falls back to the system font. Follow the Fonts guide to add them or use your own.