安装
安装 Nex UI, 快速开发应用程序!
搭建第一个 NexUI 项目
CLI 需要 Node.js 版本 20+,当您的包管理器发出警告时,请注意升级您的 Node 版本。
使用 CLI 是启动 NexUI 项目最简单的方式。您可以直接通过以下命令初始化项目:
undefined
npx @nex-ui/cli init
然后,根据提示操作!
您也可以通过 CLI 的命令行选项直接指定项目的名称以及模版。例如,您想创建一个使用 App Router 的 Next.js 应用:
undefined
npx @nex-ui/cli init nexui-app -t next-app
目前支持模版有:next-app
、next-pages
、vite
、vite-swc
。
手动安装
在您的项目中,可以用以下方法来安装 NexUI:
undefined
npm install @nex-ui/react @emotion/react
请注意,react
和 react-dom
是 PeerDependencies
,这意味着您应该确保在安装 Nex UI 之前安装它们。
"peerDependencies": {
"react": "^19.0.0",
"react-dom": "^19.0.0"
}
之后,需在应用的入口文件中添加 NexUIProvider
。
import { NexUIProvider } from '@nex-ui/react'
function App() {
return (
<NexUIProvider>
<YourApplication />
</NexUIProvider>
)
}
接下来在应用程序中,您就可以使用 NexUI 的组件了:
import { Button } from '@nex-ui/react'
function Home() {
return <Button>Press me</Button>
}
最后更新时间