One React Framework
repository·main·Indexed 26 days ago
https://github.com/onejs/oneA React Framework that leverages Vite to serve both native mobile and web platforms from a single codebase. It features a Stack Header Composition API for declarative JSX configuration of native navigation headers, a set of headless UI components via `one/ui` for tab systems, and `@vxrn/mdx-rust`, a high-performance MDX pipeline using the satteri Rust-based parser and Expressive Code for syntax highlighting.
What's inside One
- One is a React framework designed for full-stack development that enables targeting both React Native and web from a single codebase. It replaces both Metro and separate web frameworks with a unified framework using shared file-system routing. One runs on Vite and supports multiple render modes (SSG, SSR, SPA, and API) on a per-page basis. For native builds, it supports Metro (recommended for stability) and an experimental Vite-based bundler.
Overview of @vxrn/mdx-rust
main@vxrn/mdx-rust is a high-performance MDX pipeline for One. It uses the satteri Rust-based parser for fast Markdown/MDX compilation and Expressive Code (Shiki) for syntax highlighting. It includes built-in support for GFM, SmartyPants, frontmatter, and:::directives. It is designed as a faster, lighter replacement for themdx-bundler+ remark/rehype stack used in@vxrn/mdx.Overview of One React Framework
mainOne is a React Framework designed to allow Vite to serve both native (mobile) and web platforms from a single codebase. It leverages Vite to unify the development and serving experience across these environments.Compare One vs Next.js
mainOne differs from Next.js in its approach to data and platform support:
- Data Fetching: One uses loaders (similar to Remix) instead of React Server Components (RSC). It recommends pairing with a sync engine like Zero.
- Cross-Platform: One targets React Native alongside web with a single codebase, whereas Next.js is web-focused.
- Out-of-the-box features: One includes image optimization, dynamic OpenGraph images, automatic sitemaps, a Hono production server, and API routes.
Understand One file-system routing
mainOne uses file-system routing within the
appdirectory. Every.tsxfile inappbecomes a route (a "page"), except for_layout.tsx,_middleware.tsx, or files matching yourignoredRouteFilesconfiguration.Pages must export a React component. You can use
export defaultor a namedexport. Using a named export (the first capitalized one found) is recommended for better hot reloading support with React Refresh.Understand the Cloudflare Worker Build Pipeline
mainThe Cloudflare build process consists of four sequential passes to generate the necessary assets and the worker entry point:
- Pass 1 (Client + Server): Runs
viteBuild()for bothclientandssrenvironments.- Outputs
dist/client/*(static assets) anddist/server/*(server entry and shared chunks).
- Outputs
- Pass 2 (API Routes): Runs
buildCustomRoutes('api', ...)to create fully-bundled ES modules for each API route.- Outputs
dist/api/api/<route>.js.
- Outputs
- Pass 3 (Middlewares): Runs
buildCustomRoutes('middlewares', ...)to bundle middleware files.- Outputs
dist/middlewares/.
- Outputs
- Pass 4 (Cloudflare Worker): Generates a
_worker-src.jsfile that creates alazyRoutesmap using dynamic imports pointing to the outputs of Passes 1, 2, and 3. This file is then bundled into the finaldist/worker.jsanddist/wrangler.jsoncusing@cloudflare/vite-pluginto ensure proper polyfilling and CJS compatibility.
- Pass 1 (Client + Server): Runs
Access One documentation
mainFor comprehensive guides, API references, and detailed information about the One Stack Header Composition API, visit the official documentation website at https://onestack.dev.Compare One vs Expo Router
mainWhile One started as a fork of Expo Router, it has diverged to provide several web-specific optimizations:
- Rendering: One supports SSG, SSR, and SPA on a per-page basis via render modes. Expo Router is SPA-only on web.
- Performance: One achieves higher Lighthouse scores through optimized loading and code splitting.
- Server Features: One includes a Hono-based production server, middleware for request interception/auth, and typed loaders that tree-shake out of client bundles.
- Dev Tools: One provides built-in dev tools (Alt+Space) with SEO preview, route debugging, and a source inspector.
Note: Expo Router currently supports features One does not, such as
use domand RSC support.Check One project stability and feature status
mainOne features different stability stages for its components and platforms. Features in the
developingstage or later are considered available for use.Stability Stages:
earlydeveloping(Available to use)mostly-stable(Available to use)stable(Available to use)
Compare One vs TanStack Start
mainBoth are Vite-based, but they differ in configuration and execution:
- Render Mode Configuration: One uses file suffixes (e.g.,
page+ssg.tsx,page+ssr.tsx) and supports adefaultRenderMode. TanStack uses route property configuration. - Static Generation: One's SSG runs loaders at build time to output static HTML. TanStack's static prerendering is a post-build crawl.
- Loader Execution: One's loaders run on the server and tree-shake out of client bundles. TanStack's loaders are isomorphic (running on server and then again on client during navigation).
- Platform Support: One targets web and native; TanStack Start is web-only.
- Render Mode Configuration: One uses file suffixes (e.g.,
Set up Tamagui
mainFollow the guide to integrate Tamagui into your One project for advanced UI styling and component management.Configure devtools in vite.config.ts
mainOne provides development tools to debug and understand your app. These are enabled by default in development mode. You can enable/disable them all at once or configure individual tools like
inspectorandseoPreviewvia theoneplugin configuration invite.config.ts.Available tools:
- inspector: Hold Shift+Cmd (Mac) or Shift+Ctrl (Windows/Linux) and hover over an element to see its source file location and click to open it.
- seoPreview: Press Alt+S to toggle a panel showing Google Search, Open Graph, and Twitter Card previews.
- routeDebug: Press Alt+R to view current route state (Pathname, Segments, Params, etc.).
- loaderTiming: Press Alt+L to view a performance waterfall for route loaders.
- routePreload: Press Alt+P to view preloaded routes (Note: preloading only works in production builds).
- errorPanel: Press Alt+E to view a history of errors caught by error boundaries and loaders.
export default { plugins: [ one({ // Enable all devtools (default) devtools: true, // Disable all devtools devtools: false, // Configure individual tools devtools: { inspector: true, // enabled by default seoPreview: true, // enabled by default }, }), ], }