uniwind-plugin-next
v1.4.2
Published
Compatibility plugin for using Uniwind with Next.js
Readme
uniwind-plugin-next
Uniwind config plugin for Next.js projects using Webpack. Turbopack-based projects are not supported at this stage.
✅ Supports both Uniwind and Uniwind Pro
Example
See a fully working example project here: Demo (Source)
Compatibility
See the table below for tested versions of uniwind-plugin-next and corresponding versions of uniwind. Other versions of uniwind may work, but are not guaranteed to.
Tested on Next 16.1, but other versions will likely work fine.
| Uniwind | Uniwind Pro | uniwind-plugin-next |
|-------------------|----------------|---------------------|
| 1.2.7 | 1.0.0-beta.9 | 1.4.2 |
| 1.2.4 - 1.2.6 | N/A | 1.3.0 |
| 1.2.2-1.2.3 | N/A | 1.2.0 |
Installation & setup
This setup guide assumes you already have a next.js project setup with Tailwind v4
- Install uniwind and this plugin. You will probably also need
@expo/next-adapterif you don't already have it, to handle react-native web support.
pnpm install uniwind uniwind-plugin-next @expo/next-adapter- Wrap next.js config with
withUniwind()
// next.config.ts
import type { NextConfig } from "next";
import { withExpo } from "@expo/next-adapter";
import { withUniwind } from 'uniwind-plugin-next'
const nextConfig: NextConfig = {
transpilePackages: ['react-native', 'react-native-web'],
};
// Wrap your config with `withUniwind()`
export default withUniwind(withExpo(nextConfig), {
cssEntryFile: './app/globals.css',
// Takes the same options as the vite & metro plugins.
// See https://docs.uniwind.dev/api/metro-config#configuration-options
});- Add the postcss plugin
const config = {
plugins: {
'uniwind-plugin-next/postcss': {}, // Add this line
'@tailwindcss/postcss': {},
},
};
- Add
@import 'uniwind';to the global CSS file (or wherever you@import 'tailwindcss')
/* src/app/globals.css */
@import 'tailwindcss';
@import 'uniwind';- Add
suppressHydrationWarningto root<html>tag (inapp/layout.tsxby default)
// src/app/layout.tsx
...
return (
<html lang="en" suppressHydrationWarning>
...
</html>
);- Start the dev server to generate
uniwind-types.d.ts. Make sure that it's included in yourtsconfig.json'sincludearray.
SSR Considerations
This plugin marks all Uniwind web components with
'use client'automatically, so you do not need to do this manually.Be aware that some Uniwind features, such as
withUniwindanduseResolveClassNameswill not work in a server environment, as they rely on accessingwindowordocument.
