Live demo: Next.js Boilerplate
Developer experience first, extremely flexible code structure and only keep what you need:
@
prefixBuilt-in feature from Next.js:
Run the following command on your local environment:
npm run dev
Open http://localhost:3000 with your favorite browser to see your project.
To get started, you will need to create a Clerk account at Clerk.com and create a new application in the Clerk Dashboard. Once you have done that, copy the NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY
and CLERK_SECRET_KEY
values and add them to the .env.local
file (not tracked by Git):
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_pub_key
CLERK_SECRET_KEY=your_clerk_secret_key
Now you have a fully functional authentication system with Next.js, including features such as sign up, sign in, sign out, forgot password, reset password, update profile, update password, update email, delete account, and more.
.
βββ README.md # README file
βββ .github # GitHub folder
βββ .husky # Husky configuration
βββ .storybook # Storybook folder
βββ .vscode # VSCode configuration
βββ public # Public assets folder
βββ src
β βββ app # Next JS App (App Router)
β βββ core # Contains core logic and Clean Architecture layers.
β β βββ application # Application-level logic and business rules.
β β β βββ repositories # Interfaces for repositories, defining how data should be handled (e.g., CRUD operations).
β β β βββ services # Business services that interact with repositories and execute application logic.
β β β βββ use-cases # Specific use cases for the application, implementing business logic using services and repositories.
β β βββ entities # Domain entities and business logic.
β β β βββ models # Domain models representing the core data structures (e.g., User, Product).
β β β βββ dto # Data Transfer Objects used to define the shape of data sent or received.
β β βββ infrastructure # Handles communication with external systems (e.g., APIs).
β β β βββ services # Concrete service implementations.
β β β βββ repositories # API and database communication implementations
β βββ components # React components ( maybe use atomic design )
β βββ styles # Styles folder
β βββ utils # Utilities folder
βββ tailwind.config.js # Tailwind CSS configuration
βββ tsconfig.json # TypeScript configuration
public/apple-touch-icon.png
, public/favicon.ico
, public/favicon-16x16.png
and public/favicon-32x32.png
: your website faviconnext.config.ts
: Next.js configuration.env
: default environment variablesYou have full access to the source code for further customization. The provided code is just an example to help you start your project. The sky's the limit π.
The project follows the Conventional Commits specification, meaning all commit messages must be formatted accordingly. To help you write commit messages, the project uses Commitizen, an interactive CLI that guides you through the commit process. To use it, run the following command:
npm run commit
One of the benefits of using Conventional Commits is the ability to automatically generate a CHANGELOG
file. It also allows us to automatically determine the next version number based on the types of commits that are included in a release.
During the build process, database migrations are automatically executed, so there's no need to run them manually.
Then, you can generate a production build with:
$ npm run build
It generates an optimized production build of the boilerplate. To test the generated build, run:
$ npm run start
You also need to defined the environment variables CLERK_SECRET_KEY
using your own key.
This command starts a local server using the production build. You can now open http://localhost:3000 in your preferred browser to see the result.
Next.js Boilerplate includes a built-in bundle analyzer. It can be used to analyze the size of your JavaScript bundles. To begin, run the following command:
npm run build-stats
If you are VSCode user, you can have a better integration with VSCode by installing the suggested extension in .vscode/extension.json
. The starter code comes up with Settings for a seamless integration with VSCode. The Debug configuration is also provided for frontend and backend debugging experience.
With the plugins installed in your VSCode, ESLint and Prettier can automatically fix the code and display errors. The same applies to testing: you can install the VSCode Vitest extension to automatically run your tests, and it also shows the code coverage in context.
Pro tips: if you need a project wide-type checking with TypeScript, you can run a build with Cmd + Shift + B on Mac.
Everyone is welcome to contribute to this project. Feel free to open an issue if you have any questions or find a bug. Totally open to suggestions and improvements.
Licensed under the MIT License, Copyright Β© 2024
Made with β₯ by LiamPham
Looking for a custom boilerplate to kick off your project? I'd be glad to discuss how I can help you build one.