@apexnative/navigation

中文文档
1.0.0-alpha.11发布于 2026/10/31MITTypeScriptCommonJS零依赖构建来源已验证近 30 天下载 2038

Native navigation for React Native: platform stacks, tabs, modals and side menus on iOS, iPadOS and Android

原始使用文档
文档目录9 节
  1. Why
  2. A quick look
  3. What's in it
  4. When it fits
  5. Requirements
  6. Installation
  7. Principles
  8. Contributing
  9. License
@apexnative/navigation: native navigation for React Native on iOS, iPadOS and Android

npm version npm downloads CI Platforms: iOS, iPadOS, Android React Native 0.85 or newer, New Architecture TypeScript types included License: MIT

Documentation · Quick start · API reference · Releases

@apexnative/navigation

The platform owns the navigation. React describes it.

@apexnative/navigation gives a React Native app the navigation of the platform itself. Stacks, tabs, modals, side menus, split views and overlays are the real containers of iOS and Android: UINavigationController, UITabBarController, sheets with detents, UISplitViewController, the Android back stack and the Material components. You describe the screens and how they are arranged in TypeScript; the native side shows them and reports back.

Status: a pre-release on npm; the API can still change before 1.0. The current version is on the releases page.

Why

The platform already knows how to navigate. iOS and Android hold years of decisions about gestures, accessibility, every screen size, memory and multitasking. A router that keeps its own model of the navigation has to mirror all of that in JavaScript and catch up with every OS release. This library gives React the platform's own containers instead of replacing them, so a new tab bar or toolbar of the OS arrives with its beta, not a year later.

Native behavior, not only a native look. The swipe back, the back button and dragging a sheet are the system's own, with the same transitions, accessibility and memory use as in an app written in Swift or Kotlin. Nothing is replayed into a copy of the state in React: JavaScript reads the state of the platform through events and hooks.

Describe, don't command. Native navigation usually speaks in JSON layouts and string ids, so a wrong screen name or a missing prop shows up at run time. Here screens, props and roots are typed, and the same mistake is an error in the editor.

A router in the React treeNative navigation by commandsThis library
Who owns the statean object in the React treethe OSthe OS
Gesturesnative or drawn in JS, synced back into Reactthe system's ownthe system's own
How you navigatenavigator components or files as URLsJSON layouts and screen idsStack, Tabs, SideMenu; commands without ids
Typestyped route paramsstrings, props uncheckednames, props and roots checked

A quick look

A screen is a component with its options:

import { Text } from 'react-native';
import { defineScreen } from '@apexnative/navigation';

function Details({ title }: { title?: string }) {
  return <Text>{title ?? 'Details'}</Text>;
}

export const DetailsScreen = defineScreen({
  component: Details,
  options: (s, props) => s.title(props.title ?? 'Details'),
});

The navigation names the screens and the root:

import { createNavigation } from '@apexnative/navigation';

export const Navigation = createNavigation({
  screens: { Home: HomeScreen, Details: DetailsScreen },
  root: 'Home',
});

Any screen opens another one with the platform's own transition:

const navigation = useNavigation();
navigation.push('Details', { props: { title: 'Order 42' } });
// navigation.push('Detail') or a prop Details doesn't take: a TypeScript error

What's in it

  • Containers: native stacks, tabs, modals and sheets, side menus, split views on iPad, and overlays, nested in each other: tabs of stacks, a stack in a modal, tabs in a side menu.
  • Screen UI as options: the top bar, bar buttons, search, the toolbar and the floating action button, the status bar and the system bars.
  • No safe area code: every screen keeps its top and sides clear of the bars and the cutout by itself; the bottom is free, and a list adds useSafeAreaInsets().bottom.
  • Native screens: SwiftUI, UIKit and Compose screens are pushed, presented and put in tabs the same way as React screens.
  • One React tree when you want it: each screen is its own React root by default; with appProvider all screens share one tree.
  • The app's lifecycle: cold start, the splash screen, deep links, notifications and switching roots on sign-in and sign-out.
  • A CLI, apex-navigation: sets up an app, checks it (doctor), adds screens, deep links, icons and the splash screen, upgrades the navigation, migrates an app from another navigation library, and serves the commands and the docs to AI coding agents (mcp).

When it fits

  • Apps that should look and behave like the platform, on iPhone, iPad and Android.
  • Apps with native screens, or a team that also writes Swift or Kotlin.
  • Apps where startup, transitions and memory matter.

It doesn't fit an app that also ships to the web, or one that draws the same fully custom UI on every platform in JavaScript.

Requirements

React Native0.85 or newer, with the New Architecture (bridgeless, Fabric)
iOS and iPadOS15.1 or newer
Android7.0 or newer (minSdk 24)
Exponot supported by setup yet
Webnot a target

Installation

npm install @apexnative/navigation
npx apex-navigation setup

setup shows what it changes in the native files and in index.js, asks before writing, and installs the pods on a Mac. A new app starts with npx @apexnative/navigation init MyApp, and npx apex-navigation doctor checks an app and the machine and fixes what it can. The installation guide has the details, and the quick start builds a first app with two screens.

Coming from another library: React Navigation, Expo Router, react-native-navigation.

Principles

  1. The platform leads. Native stacks, tabs, sheets and gestures, not a web-style router. A URL is one entry point among push notifications, widgets and shortcuts.
  2. Native is the source of truth. Navigation state, screen lifecycle, safe areas, keyboard and theme come from the OS.
  3. App lifecycle is first-class. Cold start, splash, session restore, background and process death are explicit steps.
  4. New OS features, fast. Support for new iOS and Android releases lands with the betas.
  5. Customization without losing native behavior. Options of system components first, your own native components inside native containers next, custom JS UI last.
  6. Performance is a requirement. Transitions and gestures run natively; JavaScript stays off the critical path.
  7. Rendering and logic apart. React renders screens. The logic of the app (a socket, a session, services) lives outside the render tree: navigation works outside React, and willMount prepares the app before the first screen.

When two of them pull apart, the order decides.

Contributing

The Showcase app runs every feature as a scenario. See CONTRIBUTING.md and the code of conduct.

License

MIT

版本与发布记录

@apexnative/navigation 共发布 13 个版本,首次发布于 2026/10/22;过去 12 个月发布了 13 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.0.0-alpha.11latest2026/10/317 天前
1.0.0-alpha.102026/10/317 天前
1.0.0-alpha.92026/10/308 天前
1.0.0-alpha.82026/10/309 天前
1.0.0-alpha.72026/10/299 天前
1.0.0-alpha.62026/10/2513 天前

关于 @apexnative/navigation 的常见问题

@apexnative/navigation 是什么?

Native navigation for React Native: platform stacks, tabs, modals and side menus on iOS, iPadOS and Android

如何安装 @apexnative/navigation?

在项目目录运行 npm install @apexnative/navigation,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(*)、react-native(>=0.85.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。它还提供命令行工具 apex-navigation,可以用 npx apex-navigation 直接运行。

@apexnative/navigation 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@apexnative/navigation 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@apexnative/navigation 可以商用吗?

@apexnative/navigation 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@apexnative/navigation 的下载量有多少?

根据 npm 官方下载统计,@apexnative/navigation 在 2026/10/06 – 2026/11/04 这 30 天内被下载 2,038 次,日均约 68 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@apexnative/navigation 还在维护吗?

最新版本 1.0.0-alpha.11 发布于 2026/10/31(7 天前);至今共发布 13 个版本,其中过去 12 个月发布了 13 个;首次发布于 2026/10/22。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。