One React Framework
raw JSON →One is an innovative React framework designed to unify web and native application development from a single codebase, leveraging Vite as its core bundler for both environments. Currently at version 1.15.10, it integrates with React 19.2.0 and React Native 0.83.2. This framework aims to simplify full-stack development by providing features like typed file-system routing, per-page render modes (SPA, SSR, SSG), and loaders, abstracting away complex platform-specific configurations and build processes. Its key differentiator is a focus on a cohesive, performant developer experience for hybrid apps, aiming to replace traditional setups involving Metro for native and separate web frameworks. One originated from the experience of building cross-platform apps with Tamagui Takeout and at Uniswap, highlighting its practical, production-oriented approach.
Common errors
error Invariant Violation: requireNativeComponent: "RNSScreen" was not found in the UIManager. ↓
cd ios && pod install. For Android, rebuild the project: cd android && ./gradlew clean then npx react-native run-android. Sometimes clearing Metro cache (npx react-native start --reset-cache) and reinstalling node_modules helps. error Something went wrong installing the "sharp" module. Cannot find module '../build/Release/sharp-linux-x64.node' ↓
sharp is installed in the target environment (e.g., inside a Docker container matching your Lambda runtime for serverless deployments). On local development, try npm rebuild sharp or npm install sharp --verbose. Delete node_modules and package-lock.json (or yarn.lock), then reinstall. error TypeError: (0, _reactNativeScreens.useScreens) is not a function ↓
react-native-screens and @react-navigation/native (and other @react-navigation packages) are compatible versions. Ensure you are importing enableScreens() or similar setup functions if required by your specific react-native-screens version, typically at the app's entry point. Warnings
breaking One is built on React 19, which introduces significant breaking changes including changes to `forwardRef`, removal of `PropTypes`, and stricter `useEffect` behavior in Strict Mode. Migrating existing React 18 codebases or integrating non-React 19 compatible libraries will require careful attention. ↓
gotcha The `sharp` peer dependency can lead to installation issues due to its native binaries. Errors like 'Cannot find module 'sharp-linux-x64.node'' are common, especially in CI/CD environments or when deploying to different operating systems. ↓
breaking React Native versions and their ecosystem dependencies (like `react-native-screens`, `react-native-reanimated`, `react-navigation`) are tightly coupled. Upgrading 'one' might necessitate specific versions of these peer dependencies, potentially causing conflicts with other parts of your React Native project if not managed carefully. ↓
gotcha As a new framework, 'one' is likely to have a rapid release cycle, potentially introducing frequent minor breaking changes or API shifts as it matures. ↓
Install
npm install one yarn add one pnpm add one Imports
- config wrong
const { defineConfig } = require('@one/vite-plugin');correctimport { defineConfig } from '@one/vite-plugin'; export default defineConfig({}); - App wrong
import App from 'one'; // One typically provides a named export for the root App component.correctimport { App } from 'one'; function MyRootApp() { return <App initialRoute='/'>...</App>; } - useLoader wrong
import { useLoader } from 'one'; // Incorrect subpath for server-side utilities.correctimport { useLoader } from 'one/server'; function MyComponent() { const data = useLoader((ctx) => { // Server-side data fetching logic return { message: 'Hello from loader!' }; }); return <p>{data.message}</p>; }
Quickstart
import { App, Text, View } from 'one';
import React from 'react';
// Define a root layout component that can adapt to web and native
function RootLayout({ children }: { children: React.ReactNode }) {
return (
<View style={{
flex: 1,
justifyContent: 'center',
alignItems: 'center',
padding: 20,
backgroundColor: '#f0f0f0',
}}>
<Text style={{
fontSize: 24,
fontWeight: 'bold',
marginBottom: 20,
color: '#333'
}}>
Welcome to One!
</Text>
{children}
</View>
);
}
// Define a page component, e.g., for '/'
function HomePage() {
return (
<View>
<Text style={{ fontSize: 18, color: '#555' }}>
This is a hybrid web and native app.
</Text>
<Text style={{ fontSize: 16, marginTop: 10, color: '#777' }}>
Edit src/app/index.tsx to get started.
</Text>
</View>
);
}
// One framework entry point
export default function OneApp() {
return (
<App initialRoute="/">
<RootLayout>
{/* File-system based routing expects components in `src/app` */}
{/* For demonstration, we'll render HomePage directly */}
<HomePage />
</RootLayout>
</App>
);
}