Navigation

@solidnative-dev/navigation pairs @tanstack/router-core (type-safe routes, params, search, loaders, and navigation blockers) with real native iOS (UINavigationController / UITabBarController) and Android (Fragment / Material tabs) containers via a verified react-native-screens backend.

Add navigation to an app#

sh
sn add navigation

The CLI installs exact matched @solidnative-dev/navigation and react-native-screens versions, copies the content-addressed native patch into patches/, merges patchedDependencies into pnpm-workspace.yaml, reinstalls, and verifies the patched native files by SHA-256.

Native stack with TanStack Router#

tsx
/** @jsxImportSource @solidnative-dev/core */
import {
  TanStackNativeLink,
  TanStackNativeRouterProvider,
  TanStackNativeStack,
  TanStackRootRoute,
  TanStackRoute,
  createTanStackNativeHistory,
  createTanStackNativeRouter,
} from "@solidnative-dev/navigation";
import { Text, View } from "@solidnative-dev/core";

const rootRoute = new TanStackRootRoute();
const homeRoute = new TanStackRoute({
  getParentRoute: () => rootRoute,
  path: "/",
  component: () => (
    <View>
      <Text>Home</Text>
      <TanStackNativeLink to="/details">Open details</TanStackNativeLink>
    </View>
  ),
});
const detailsRoute = new TanStackRoute({
  getParentRoute: () => rootRoute,
  path: "/details",
  component: () => <Text>Details screen</Text>,
});

const history = createTanStackNativeHistory({ initialEntries: ["/"] });
const router = createTanStackNativeRouter({
  routeTree: rootRoute.addChildren([homeRoute, detailsRoute]),
  history,
});

export function AppNavigator() {
  return (
    <TanStackNativeRouterProvider router={router}>
      <TanStackNativeStack router={router} history={history} />
    </TanStackNativeRouterProvider>
  );
}

What's supported#

  • Native stacks & headers: hardware back button, iOS swipe-back gestures, native header titles, search bars, and subviews.
  • Native tabs (NativeTabs): per-tab stacks, scroll-to-top, badges, and iOS/Android appearance customization.
  • Sheets & modals (NativeModalStack): detent sheets, interactive dismissal, and composed interruption handling.
  • Safety & continuity: navigation blockers, deep-link URL normalization, scroll-offset restoration, and bounded process-restoration snapshots.
  • Causal ownership: router transitions preserve causal scopes across startTransition and router.batch, so every navigated mount traces back to the tap that triggered it.