Registry / web-framework / vite-plugin-react-native-web

vite-plugin-react-native-web

JSON →
library3.1.2jsnpmunverified

A Vite plugin that adds React Native Web support to Vite projects. It strips Flow types, aliases `react-native` to `react-native-web`, and transforms .js files as .jsx using ESBuild. Current stable version is 3.1.2, with a moderate release cadence. Key differentiators: first-class Vite integration, supports Expo and non-Expo projects, and defines global variables like `__DEV__` and `process.env.EXPO_OS`. Requires `react-native-web` and `inline-style-prefixer` as peer dependencies.

npm install vite-plugin-react-native-web
INSTALL
IMPORT
SIG · VITE-PLUGIN-REACT-
V
vite-plugin-react-native-web
web-frameworkjavascriptv3.1.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import reactNativeWeb from 'vite-plugin-react-native-web'
const reactNativeWeb = require('vite-plugin-react-native-web')
ESM-only; CommonJS require will fail in Vite configs that use ESM.
reactNativeWeb (named)
import { reactNativeWeb } from 'vite-plugin-react-native-web'
import reactNativeWebPlugin from 'vite-plugin-react-native-web'
Named export available since v3; default export is the function itself.
defineConfig
import { defineConfig } from 'vite'
import { defineConfig } from 'vite-plugin-react-native-web'
defineConfig is from Vite, not this plugin.

This shows how to install and configure the plugin in a Vite project with TypeScript.

// vite.config.ts import { defineConfig } from 'vite'; import reactNativeWeb from 'vite-plugin-react-native-web'; export default defineConfig({ plugins: [ reactNativeWeb({ // Optional: customize global variable definitions // variables: { // __DEV__: true, // 'process.env.EXPO_OS': '"web"', // }, }), ], });
Debug
Known issues
breakingVite 8 support requires v3.0.0+. Older versions (v2.x) are incompatible with Vite 8.
fix
Upgrade vite-plugin-react-native-web to >=3.0.0.
affects: >=8.0.0
deprecatedThe 'expo' option for manualChunks was disabled by default in v2.7.0.
fix
If you rely on Expo's manualChunks, re-enable via plugin options: reactNativeWeb({ expo: { manualChunks: true } }).
affects: >=2.7.0
gotchaPeer dependencies (react-native-web, inline-style-prefixer) must be in the app's own node_modules directory, especially with pnpm or workspaces.
fix
Run `pnpm add react-native-web inline-style-prefixer` in the app directory.
affects: >=1.0.0
gotchaThe plugin transforms files with .js extension as .jsx; ensure your JS files are valid JSX to avoid parsing errors.
fix
Rename .js files containing JSX to .jsx or configure ESBuild loader.
affects: >=1.0.0
breakingIncorrect CommonJS resolution fixed in v3.1.0; previous versions may have issues with some dependencies.
fix
Upgrade to v3.1.0+.
affects: <3.1.0
Errors
Common errors & fixes
Error: Cannot find module 'react-native-web'
Missing peer dependency react-native-web.
fix
Run `npm install react-native-web` or `pnpm add react-native-web`.
Error: Module "vite-plugin-react-native-web" has been externalized for browser compatibility
Using this plugin in a browser context (e.g., Vite SSR) incorrectly.
fix
Ensure this plugin is only used in the Vite config's plugins array, not imported in browser code.
TypeError: Cannot read properties of undefined (reading 'split')
The plugin encountered a file that is not a valid React Native module.
fix
Check that your source files are properly structured and use standard react-native imports.
Upgrade
Version history
3.1.2latest on npm
Audit
Dependencies
react-native-webrequiredCore runtime replacement for react-native in web builds.
inline-style-prefixerrequiredRequired by react-native-web for CSS vendor prefixing.
Agent activity
5 hits · last 30 days
node
4
OpenAI (training)
1
Resources
vite-plugin-react-native-web — npm install vite-plugin-react-native-web · libregistry