|
| 1 | +--- |
| 2 | +id: next-js |
| 3 | +title: Next Js Getting Started |
| 4 | +sidebar_label: Next JS |
| 5 | +sidebar_position: 26 |
| 6 | +tags: [NextJS, Routing, Page Routing] |
| 7 | +description: This docs contains about the Next JS documentation |
| 8 | +--- |
| 9 | + |
| 10 | + |
| 11 | +## Get Started |
| 12 | + |
| 13 | +To start using Aceternity UI in your projects, simply install the library via your preferred package manager: |
| 14 | + |
| 15 | +### Next.js |
| 16 | + |
| 17 | +```bash |
| 18 | +npx create-next-app@latest |
| 19 | +``` |
| 20 | +On Installation, you will be prompted to choose a template. Select the default template and proceed with the installation. |
| 21 | + |
| 22 | +```bash |
| 23 | +What is your project named? my-app |
| 24 | +Would you like to use TypeScript? No / Yes |
| 25 | +Would you like to use ESLint? No / Yes |
| 26 | +Would you like to use Tailwind CSS? No / Yes |
| 27 | +Would you like to use `src/` directory? No / Yes |
| 28 | +Would you like to use App Router? (recommended) No / Yes |
| 29 | +Would you like to customize the default import alias (@/*)? No / Yes |
| 30 | +What import alias would you like configured? @/* |
| 31 | + |
| 32 | +``` |
| 33 | +After the prompts, `create-next-app` will create a folder with your project name and install the required dependencies. |
| 34 | + |
| 35 | +Create a root layout inside `app/layout.tsx` with the required `<html>` and `<body>` tags: |
| 36 | + |
| 37 | +```tsx |
| 38 | +// app/layout.tsx |
| 39 | + |
| 40 | +export default function RootLayout({ |
| 41 | + children, |
| 42 | +}: { |
| 43 | + children: React.ReactNode |
| 44 | +}) { |
| 45 | + return ( |
| 46 | + <html lang="en"> |
| 47 | + <body>{children}</body> |
| 48 | + </html> |
| 49 | + ) |
| 50 | +} |
| 51 | +``` |
| 52 | +Finally, create a home page `app/page.tsx` with some initial content: |
| 53 | + |
| 54 | +```tsx |
| 55 | +// app/page.tsx |
| 56 | +export default function Page() { |
| 57 | + return <h1>Hello, Next.js!</h1> |
| 58 | +} |
| 59 | +``` |
| 60 | +Now, you can start the development server: |
| 61 | + |
| 62 | +Run `npm run dev` to start the development server. |
| 63 | +Visit `http://localhost:3000` to view your application. |
| 64 | +Edit `app/page.tsx` (or `pages/index.tsx`) file and save it to see the updated result in your browser. |
0 commit comments