This is our standard Next.js project structure and setup guidelines. Follow these to ensure consistency across our projects.
-
Project Structure:
- Only keep Next.js routing files in the
app
directory - Implement dynamic imports for code splitting
- Create custom components in
components/
- Only keep Next.js routing files in the
-
Styling:
- Use Tailwind CSS for styling
- Use ShadCn UI components
-
Performance Optimization:
- Dynamically import components to improve performance through lazy loading
- Use server-side rendering when possible for better performance
- Use Next.js Image component for optimized images
- Always use
fetchy
, a fetch wrapper function from @/lib/fetchy, for making HTTP requests
-
Forms and Validation:
- Use React Hook Form for form handling
- Use Zod for form validations
-
State Management:
- Use Zustand for global state management
- Utilize TanStack Query for server state management
-
Environment Variables:
- Use
.env.local
for local environment variables - Never commit
.env.local
to version control
- Use
- Clone the repo:
git clone https://github.com/CeyLabs/Next-ShadCN-Template.git
- Install Dependencies:
bun i
- Run the Development Server:
bun dev
- Open http://localhost:3000 in your browser.
Before committing, ensure your code is properly formatted and builds without errors:
bun run format
bun run build
feat
: for new featuresfix
: for bug fixesdocs
: for documentation changesstyle
: for formatting changesrefactor
: for code refactoringtest
: for adding or modifying testschore
: for maintenance tasks
- Create a new branch for each feature or fix
- Submit a pull request for review before merging to the main branch
project-root/
├── src/
│ ├── app/
│ │ ├── layout.tsx
│ │ ├── page.tsx
│ │ └── [...route]/
│ │ └── page.tsx
│ ├── components/
│ │ ├── ui/
│ │ │ ├── Button.tsx
│ │ │ └── Input.tsx
│ │ └── layout/
│ │ ├── Header.tsx
│ │ └── Footer.tsx
│ ├── utils/
│ │ └── cn.ts
│ ├── hooks/
│ │ └── useCustomHook.ts
│ ├── styles/
│ │ └── theme.css
│ │ └── globals.css
│ └── types/
│ └── index.ts
├── public/
│ ├── images/
│ └── fonts/
├── tests/
│ └── componentName.test.tsx
├── .env.local
├── .gitignore
├── next.config.js
├── package.json
├── README.md
└── tsconfig.json