Docs
Next.js
Next.js
Install and configure Next.js.
Create project
Start by creating a new Next.js project using create-next-app:
npx create-next-app@latest my-app --typescript --tailwind --eslintRun the CLI
Run the luxdefi-ui init command to setup your project:
npx luxdefi-ui@latest initConfigure components.json
You will be asked a few questions to configure components.json:
Would you like to use TypeScript (recommended)? no / yes
Which style would you like to use? › Default
Which color would you like to use as base color? › Slate
Where is your global CSS file? › › app/globals.css
Do you want to use CSS variables for colors? › no / yes
Where is your tailwind.config.js located? › tailwind.config.js
Configure the import alias for components: › @/components
Configure the import alias for utils: › @/lib/utils
Are you using React Server Components? › no / yesApp structure
Here's how I structure my Next.js apps. You can use this as a reference:
.
├── app
│ ├── layout.tsx
│ └── page.tsx
├── components
│ ├── ui
│ │ ├── alert-dialog.tsx
│ │ ├── button.tsx
│ │ ├── dropdown-menu.tsx
│ │ └── ...
│ ├── main-nav.tsx
│ ├── page-header.tsx
│ └── ...
├── lib
│ └── utils.ts
├── styles
│ └── globals.css
├── next.config.js
├── package.json
├── postcss.config.js
├── tailwind.config.js
└── tsconfig.json- I place the UI components in the
components/uifolder. - The rest of the components such as
<PageHeader />and<MainNav />are placed in thecomponentsfolder. - The
libfolder contains all the utility functions. I have autils.tswhere I define thecnhelper. - The
stylesfolder contains the global CSS.
That's it
You can now start adding components to your project.
npx luxdefi-ui@latest add buttonThe command above will add the Button component to your project. You can then import it like this:
import { Button } from "@/components/ui/button"
export default function Home() {
return (
<div>
<Button>Click me</Button>
</div>
)
}