To use NextUI in your Astro project, you need to follow the following steps:


In your Astro project, run one of the following command to install NextUI:

Tailwind CSS Setup

NextUI is built on top of Tailwind CSS, so you need to install Tailwind CSS first. You can follow the official installation guide to install Tailwind CSS. Then you need to add the following code to your tailwind.config.cjs file:

// tailwind.config.cjs
const { nextui } = require("@nextui-org/react");
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
// ...
theme: {
extend: {},
darkMode: "class",
plugins: [nextui()]


Now you can import NextUI components and use them in your Astro project:

import Layout from '../layouts/Layout.astro';
import {Button} from '@nextui-org/react';
<Layout title="Welcome to Astro.">
<Button color="primary" client:visible>My button</Button>

Note that you have to add client:visible to the component to make it visible only on the client side. Otherwise some functionalities of NextUI components may not work properly.

Setup pnpm (optional)

If you are using pnpm, you need to add the following code to your .npmrc file:


After modfiying the .npmrc file, you need to run pnpm install again to ensure that the dependencies are installed correctly.

Version 2 is only compatible with React 18 or later. If you are using React 17 or earlier, please use version 1 of NextUI.