Rsbuild plugin for React Native Web support
npm install rsbuild-plugin-react-native-webRsbuild plugin for React Native Web support. This plugin enables you to use React Native components in web applications built with Rsbuild.
``bash`
npm install rsbuild-plugin-react-native-web react-native-web
`ts
// rsbuild.config.ts
import { defineConfig } from '@rsbuild/core'
import { pluginReactNativeWeb } from 'rsbuild-plugin-react-native-web'
export default defineConfig({
plugins: [pluginReactNativeWeb()],
})
`
An array of additional node_modules that need to be transpiled. By default, packages starting with react-native, @react-native, expo, and @expo are already included.
`ts`
pluginReactNativeWeb({
modulesToTranspile: ['my-react-native-library'],
})
- Aliases react-native to react-native-web.web.*
- Adds file extensions with higher priority__DEV__
- Configures global variables required by React Native (, EXPO_OS`, etc.)
- Handles Flow syntax in React Native packages
- Transforms problematic code patterns for web compatibility
This plugin is inspired by vite-plugin-rnw by @dannyhw. Many of the core transformation techniques and React Native Web compatibility patterns were adapted from that project. Thanks for the great work.
MIT