Skip to main content

Expo

Set up Vortex Native in an Expo app. Vortex Native has no native code, so it runs in Expo Go and development builds.

Install the packages

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

bunx expo install @vortexlabs/vortex-native @vortexlabs/vortex-themes react-native-safe-area-context

react-native-safe-area-context keeps content clear of the status bar and home indicator. expo install picks the version that matches your Expo SDK.

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.

Follow the device color mode

New Expo apps lock the app to light mode. Set userInterfaceStyle to automatic so defaultColorMode="system" can follow the device setting:

app.json
{
  "expo": {
    "userInterfaceStyle": "automatic"
  }
}

Restart Expo after changing app.json. Development builds also need a rebuild.

Add the provider

Wrap your app in VortexProvider and pass it the theme. The provider doesn't paint the screen, so add a surface that applies the theme background and status bar style:

App.tsx
import { useTheme, VortexProvider } from "@vortexlabs/vortex-native";
import { StatusBar } from "expo-status-bar";
import type { ReactNode } from "react";
import { 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 style={colorMode === "dark" ? "light" : "dark"} />
      {children}
    </View>
  );
};

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

export default App;

With Expo Router, put the providers and surface in app/_layout.tsx around the root Stack instead.

Use a component

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;
bunx expo start

Fonts

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