This guide provides complete installation instructions for Nativewind v5 with Expo. Use this document to initialize projects with your preferred package manager.
For rapid setup, use the rn-new CLI tool:
npm:
npx rn-new@next --nativewindyarn:
yarn dlx rn-new@next --nativewindpnpx:
pnpx rn-new@next --nativewindbun:
bunx rn-new@next --nativewindThis automatically sets up a new Expo project with Nativewind v5, Expo SDK 54, and Tailwind CSS.
Install nativewind and its peer dependencies: tailwindcss, react-native-css, react-native-reanimated, and react-native-safe-area-context.
Expo CLI (Recommended for Expo projects):
npx expo install nativewind@preview react-native-css react-native-reanimated react-native-safe-area-contextnpm:
npm install nativewind@preview react-native-css react-native-reanimated react-native-safe-area-contextyarn:
yarn add nativewind@preview react-native-css react-native-reanimated react-native-safe-area-contextpnpm:
pnpm install nativewind@preview react-native-css react-native-reanimated react-native-safe-area-contextbun:
bun install nativewind@preview react-native-css react-native-reanimated react-native-safe-area-contextInstall Tailwind CSS and PostCSS as dev dependencies:
Expo CLI (Recommended for Expo projects):
npx expo install --dev tailwindcss @tailwindcss/postcss postcssnpm:
npm install --dev tailwindcss @tailwindcss/postcss postcssyarn:
yarn add --dev tailwindcss @tailwindcss/postcss postcsspnpm:
pnpm install --save-dev tailwindcss @tailwindcss/postcss postcssbun:
bun install --dev tailwindcss @tailwindcss/postcss postcssOptional: Install prettier-plugin-tailwindcss to automatically format your Tailwind CSS code.
Create a postcss.config.mjs file in the root of your project (if it doesn't already exist):
// postcss.config.mjs
export default {
plugins: {
"@tailwindcss/postcss": {},
},
};Create a global.css file in your project root and add the Tailwind directives:
/* global.css */
@import "tailwindcss/theme.css" layer(theme);
@import "tailwindcss/preflight.css" layer(base);
@import "tailwindcss/utilities.css";
@import "nativewind/theme";Note: Instead of using the standard @tailwind directives, Nativewind recommends using the @import at-rules above for better compatibility with react-native-web.
Create or modify your metro.config.js file:
-
If you don't have a
metro.config.jsfile, run:npx expo customize metro.config.js
-
Wrap the default config with
withNativewind:
// metro.config.js
const { getDefaultConfig } = require("expo/metro-config");
const { withNativewind } = require("nativewind/metro");
/** @type {import('expo/metro-config').MetroConfig} */
const config = getDefaultConfig(__dirname);
module.exports = withNativewind(config);Import the CSS file at the top of your main app file:
// App.js
import "./global.css"
export default function App() {
/* Your App */
}Important: Import your CSS file inside the same file as the top-most component of your app. Do not import it in the same file that calls AppRegistry.registerComponent or your app will not Fast Refresh properly.
Force lightningcss to version 1.30.1 in your package.json to prevent deserialization errors. The configuration differs by package manager:
npm:
{
"overrides": {
"lightningcss": "1.30.1"
}
}yarn:
{
"resolutions": {
"lightningcss": "1.30.1"
}
}pnpm:
{
"pnpm": {
"overrides": {
"lightningcss": "1.30.1"
}
}
}bun:
{
"overrides": {
"lightningcss": "1.30.1"
}
}Critical: This step is required to avoid build-time errors related to global.css deserialization.
If using TypeScript, create a nativewind-env.d.ts file in your project root:
/// <reference types="react-native-css/types" />
// NOTE: This file should not be edited and should be committed with your source code.
// It is generated by react-native-css. If you need to move or disable this file,
// please see the documentation.Quick Alternative: Run npx expo start --clear in your Expo project's root directory to generate this file automatically.
Important Naming Conventions:
- Do NOT name this file
nativewind.d.ts - Do NOT use the same name as a file or folder in the same directory (e.g.,
app.d.tswhen an/appfolder exists) - Do NOT use the same name as a folder in
node_modules(e.g.,react.d.ts)
These naming conflicts will prevent TypeScript from picking up the types correctly.
Create a test component to verify your setup:
// App.tsx
import "./global.css"
import { Text, View } from "react-native";
export default function App() {
return (
<View className="flex-1 items-center justify-center bg-white">
<Text className="text-xl font-bold text-blue-500">
Welcome to Nativewind!
</Text>
</View>
);
}If you see styled text centered on a white background, Nativewind is working correctly!
- Expo CLI: Uses
npx expo installwhich ensures version compatibility with your Expo SDK - npm: Standard
npm installornpm install --devfor dev dependencies - yarn: Uses
yarn addoryarn add --devfor dev dependencies - pnpm: Uses
pnpm installorpnpm install --save-devfor dev dependencies - bun: Uses
bun installorbun install --devfor dev dependencies
- npm, pnpm, bun: Use
"overrides"field in package.json - yarn: Uses
"resolutions"field in package.json
- For Expo projects, prefer using
npx expo installas it handles peer dependency resolution and version compatibility automatically - After adding the lightningcss override/resolution, reinstall dependencies:
- npm:
npm install - yarn:
yarn install - pnpm:
pnpm install - bun:
bun install
- npm:
- Editor Setup - Configure your IDE for Nativewind
- Other Bundlers - Use Nativewind with alternative bundlers
- Nativewind Documentation - Complete documentation and guides
- Install Nativewind and peer dependencies
- Install Tailwind CSS and PostCSS as dev dependencies
- Create
postcss.config.mjswith@tailwindcss/postcss - Create
global.csswith Tailwind imports - Configure
metro.config.jswithwithNativewind - Import
global.cssin your main app component - Pin
lightningcssto version 1.30.1 using appropriate package manager field - (TypeScript) Create
nativewind-env.d.tstype definitions - Test with a simple styled component
Version: Nativewind v5 Preview
Compatible with: Expo SDK 54+
Last Updated: 2025