Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added nextjs tutorial page #17

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions pages/development/coding-conventions/Nextjs/structure.mdx
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kinhdev24 We shouldn't show the source code structure in the coding-conventions folder, Kinh

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be on platform -> web -> source code structure

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, I will update it soon. Thanks for your feedback, anh Quynh

Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# [Next.js](https://nextjs.org/) Project Structure

This page provides an overview of the project structure of a Next.js application. It covers top-level files and folders, configuration files, and routing conventions within the `app` directories

---

### Folder structure

Most of the code lives in the `app` folder and looks something like this:

```
+-- 📂 app # app router
|
+-- 📂 project # pages router
...
|
+-- 📁 public # static assets to be served
|
+-- 📁 components # shared components used across the entire application
|
+-- 📁 config # global configurations, exported env variables etc.
|
+-- 📁 hooks # shared hooks used across the entire application
|
+-- 📁 lib # reusable libraries preconfigured for the application
|
+-- 📁 stores # global state stores
|
+-- 📁 test # test utilities and mocks
|
+-- 📁 types # shared types used across the application
|
+-- 📁 utils # shared utility functions
```

For easy scalability and maintenance, organize most of the code within the page router folder. Each page router folder should contain code specific to that feature, keeping things neatly separated. This approach helps prevent mixing feature-related code with shared components, making it simpler to manage and maintain the codebase compared to having many files in a flat folder structure. By adopting this method, you can enhance collaboration, readability, and scalability in the application's architecture.

A page router could have the following structure:

```
app/projects
|
+-- 📁 api # exported API request declarations and api hooks related to a specific feature
|
+-- 📁 assets # assets folder can contain all the static files for a specific feature
|
+-- 📁 components # components scoped to a specific feature
|
+-- 📁 hooks # hooks scoped to a specific feature
|
+-- 📁 stores # state stores for a specific feature
|
+-- 📁 types # typescript types used within the feature
|
+-- 📁 utils # utility functions for a specific feature
```

NOTE: You don't need all of these folders for every feature. Only include the ones that are necessary for the feature.

---

### See similar instructions in the NextJS documentation

###### [Top-level files](https://nextjs.org/docs/getting-started/project-structure#top-level-files)

###### [Routing Conventions](https://nextjs.org/docs/getting-started/project-structure#app-routing-conventions)

###### [Nested Routes](https://nextjs.org/docs/getting-started/project-structure#nested-routes)

###### [Dynamic Routes](https://nextjs.org/docs/getting-started/project-structure#dynamic-routes)

###### [Route Groups and Private Folders](https://nextjs.org/docs/getting-started/project-structure#route-groups-and-private-folders)

###### [Parallel and Intercepted Routes](https://nextjs.org/docs/getting-started/project-structure#parallel-and-intercepted-routes)

###### [Metadata File Conventions](https://nextjs.org/docs/getting-started/project-structure#metadata-file-conventions)

###### [Routers](https://nextjs.org/docs/getting-started/project-structure#routes)

###### [Dynamic Routers](https://nextjs.org/docs/getting-started/project-structure#dynamic-routes-1)
Loading