Skip to content
rootnativePublic

About

Planning something for the web

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Root Native Web logo

Root Native Web

npm version of @rootnative/web MIT license

@rootnative/web is a standalone web runtime for React Native apps. You write react-native. It runs in the browser as a real web app.

Early alpha. The API can change between releases. Status lists what ships today, and the changelog lists the changes in each release.

Docs: https://rootnative.github.io/web/

Why

react-native-web tracks React Native and stops there. This project starts from the browser and asks a different question: what does a React Native app need to be a good web app?

  • Parity first. Every react-native export that ships behaves as it does on iOS and Android.
  • Web second, behind the same API. Semantic HTML, SEO, server rendering, DOM events, logical CSS properties, and the browser features that native doesn't have.
  • Modern only. TypeScript, ESM, React 19. No Flow, no CommonJS, no findDOMNode, no forwardRef.

Install

npm install @rootnative/web

React 19 and React DOM 19 are peer dependencies. Add the Vite plugin to vite.config.ts. It resolves react-native to the package:

import { rootnative } from '@rootnative/web/vite'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [react(), rootnative()],
})

Give TypeScript the same mapping in src/react-native.d.ts:

declare module 'react-native' {
  export * from '@rootnative/web'
}

Installation shows how to mount the app, so that flex: 1 fills the window.

Example

import { StyleSheet, Text, View } from 'react-native'

export function App() {
  return (
    <View role="main" style={styles.screen}>
      <Text role="heading" aria-level={1} style={styles.title}>
        Hello from React Native
      </Text>
      <Text href="/about">About</Text>
    </View>
  )
}

const styles = StyleSheet.create({
  screen: { flex: 1, alignItems: 'center', justifyContent: 'center', gap: 8 },
  title: { fontSize: 24 },
})

In the browser, this is a <main> with an <h1> and an <a href="/about">, styled with atomic CSS classes. The same code runs on iOS and Android.

Learn more

Development

pnpm install
pnpm --filter @rootnative/playground dev # one route per component
pnpm docs:dev # the docs site
pnpm test # Vitest in a real Chromium
pnpm lint
pnpm typecheck
pnpm build
pnpm preflight # every CI gate, in the order CI runs them

The monorepo uses pnpm, TypeScript 7, tsdown, Vitest 5 in browser mode with Playwright, oxlint, Prettier, and Docusaurus.

packages/
  web/          @rootnative/web
  playground/   Vite app with one route per component
docs/           the docs site
scripts/        the llms, brand, and check scripts

Each component lives in one folder with its types and its tests.

After you change a docs page, run pnpm build:llms. It writes docs/static/llms-full.txt and copies docs/static/llms.txt into the package. CI fails when they don't match the pages. After an API change, also edit docs/static/llms.txt, which is written by hand.

CI runs pnpm preflight, which includes three release checks. pnpm check:versions checks that the CHANGELOG and the Status page name the version in packages/web/package.json, and pnpm check:versions:fix repairs the link footer and the Status line. pnpm check:artifact runs after the build and checks that the npm tarball has each file that exports names. pnpm check:consumer puts that tarball into the small app in e2e/consumer, checks its types, builds it with the Vite plugin, and opens the page in Chromium.

License

MIT

About

Planning something for the web

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages