Skip to content

Directory Information

Andy Erskine edited this page Apr 21, 2024 · 22 revisions

Top Level Files

Top-level files are used to configure our application, manage dependencies, run middleware, integrate monitoring tools, and define environment variables. These files include:

  • next.config.js: Configuration file for Next.js
  • package.json: Project dependencies and scripts
  • middleware.js: Next.js request middleware
  • .env.local: Local environment variables
  • .gitignore: Git files and folders to ignore
  • jsconfig.json: Configuration file for JavaScript

Top Level Folders

Top-level folders are used to organize our code base and separate the different functionalities necessary for our application. These folders include:

  • actions: This houses all of the server action functions that can be used in Server and Client Components to handle form submissions and data mutations in our application.
  • app: This defines all of the routes within the web application wherein each folder is a route and the content of that folder is what is displayed for the user or is a nested route. **This is excluding the app/css folder which specifically is used to organize all of the styling of the component within the application. **
    • Each folder acts as a route segment, for example, app/giftcard is the /giftcard route.
    • Nested folders act as nested routes, for example, app/account/membership is the /account/membership route.
    • Within each of the route folders, there are specific file conventions that define the user interface:
      • layout.js: Defines the layout of the UI that is shared between routes.
      • page.js: Defines the UI that is unique to that route.
      • not-found: Defines the UI that is displayed when a route is not defined within a segment.
      • error.js: Defines an error UI boundary for a route segment.
  • components: This houses all of our user interface components that are used within our application. Each subdirectory specifies the component that is being created for the user within the application.
  • Database: This houses all of the database-specific files needed for our application.
Clone this wiki locally