This is an opinionated baseapp for product-ready project to be used as a starting point for your project. To start, run the following commands in your terminal:
If your machine does not have pnpm
installed, you can install it by running the following command in your terminal, then restart your terminal.
npm install -g pnpm
To install all the dependencies, run the following command in your terminal.
pnpm install
To start the development server with storybook, run the following command in your terminal. This is helpful for developing components in isolation.
pnpm dev-storybook
To start the development server, run the following command in your terminal.
pnpm dev
Open http://localhost:3000 with your browser to see the result. If you are new to Next.js, you can go through the home page to learn more about the baseapp.
- Standard naming convention #
- Next.js files and folder structure cheat sheet #
- How to structure the files and folders #
- When to use server side rendering VS client side rendering #
- Standard server state management with SWR #
- Standard client state management with zustand #
- Design system with Storybook #
- Standard UI components with shadcn UI #
- Setting up a page layout #
- Setting up translation
- Setting up environments
- CRUD example walkthrough: Article
- Setting up SEO
- Setting up TDD
- Setting up CI/CD on AWS
- Setting up monitoring tools (Analytics and Crashlytics)
- Add example: logging
- Add example: error handling
-
All files and folders name should be in kebab-case. Eg:
toggle-button.tsx
orleave-management/
. -
All variables and functions should be in camelCase. eg:
const isButtonDisabled = true;
orfunction toggleButton() {}
. -
All React components should be in PascalCase, so it can be called as a React component. Eg:
<Button/>
. -
All Interfaces should be in PascalCase, and it should have a prefix of
I
or suffix ofProps
, such asinterface IButton {}
orinterface ButtonProps {}
. Eg:interface IButtonProps { isDisabled: boolean; }
-
All Types should be in PascalCase, and it should have a prefix of
T
. Eg:type TUser = { name: string; }
-
All Enums AND its contents should be in PascalCase, and it should have a prefix of
E
. Eg:EButtonColor { Primary, Secondary, Tertiary }
-
All Classes name should be in PascalCase.
- The website structure will follow the
app
folder. Each folder that havepage.tsx
will be considered a website directory.app/page.tsx
will behttps://example.com/
.app/articles/page.tsx
will behttps://example.com/articles
.app/articles/[id]/page.tsx
will behttps://example.com/articles/1
. - You can group multiple directory with
()
and the folder with()
is hidden from the URL. For example,app/(modules)/articles/page.tsx
will behttps://example.com/articles
. - You can exclude a folder from the URL by prefixing it with
_
. For example,app/_components/anything.tsx
. - You can create a dynamic route by prefixing the folder with
[]
. For example,app/[id]/page.tsx
will behttps://example.com/1
. - See example on this project to know how to pass arguments from the URL.
- Read more here. #
Your project should be structured as follows:
โโโ app
โ โโโ (modules)
โ โ โโโ leave-management (example)
โ โ โ โโโ _types
โ โ โ โ โโโ t-leave.tsx
โ โ โ โโโ _components
โ โ โ โ โโโ client-components
โ โ โ โ โ โโโ create-button.tsx
โ โ โ โ โ โโโ update-button.tsx
โ โ โ โ โโโ server-components
โ โ โ โ โ โโโ delete-button.tsx
โ โ โ โโโ _data
โ โ โ โ โโโ leave-client.tsx
โ โ โ โ โโโ utils.tsx
โ โ โ โโโ [id]
โ โ โ โ โโโ page.tsx
โ โ โ โ โโโ edit
โ โ โ โ โ โโโ page.tsx
โ โ โ โโโ create
โ โ โ โ โโโ page.tsx
โ โ โ โโโ page.tsx
โโโ components
โ โโโ toggle-button (example)
โ โ โโโ toggle-button.tsx
โ โ โโโ toggle-button.stories.tsx
โโโ public
| โโโ general
| โ โโโ default-avatar.png
| โโโ modules
| โ โโโ leave-management (example)
| โ โ โโโ example-image.png
โโโ styles
โโโ utils
- The main app directory is in the
@/app/
folder. - For shared components, they should be in the
@/components
folder. - Each shared component file should have their own folder. For example, the
Button
component should be in the@/components/button
folder. - Each shared component should have their own storybook file. For example, the
button
component should have abutton.stories.tsx
file. This way, all developers can explore the component in isolation. - All static files should be in the
@/public
folder. - All global styles should be in the
@/styles
folder. - All shared utils should be in the
@/utils
folder.
- Each main features should be in its own folder in the
@/app/(modules)
. For example, thearticles
feature should be in thearticles
folder. Or theleave-management
feature should be in theleave-management
folder. - For customized components on a per feature basis, they should be in the feature directory, which is
_components
. For example, thearticles
feature should have its own@/app/articles/_components
folder.
- For most pages, please use SSR so the first-paint will be faster. Then all dynamic contents inside the page can be rendered on client side. Why? We can use our state management to optimize the UX.
- Read more here #
Development done. Pending documentation
Development done. Pending documentation
Development done. Pending documentation
Development done. Pending documentation
- Read more here #
Development done. Pending documentation