Git Product home page Git Product logo

next.js-starter's Introduction

Next.js starter

Kick off your project with this boilerplate.

πŸš€ Quick Start

git clone
cd
yarn install
yarn run dev

your site is now running at http://localhost:3000

πŸ“ Folder Structure

A quick look at the directories you'll see in this project.

Root driectory layout

.
β”œβ”€β”€ pages               #
β”œβ”€β”€ public              #
β”œβ”€β”€ styles              #
β”œβ”€β”€ api                 #
β”œβ”€β”€ components          #
β”œβ”€β”€ context             # (alternatively `store`)
β”œβ”€β”€ hooks               # Custom hooks
β”œβ”€β”€ utils               #
β”œβ”€β”€ libs                #
β”œβ”€β”€ cypress             # Automated tests
β”œβ”€β”€ README.md           #
└── ...

Pages

Each page is associated with a route based on its file name.

.
β”œβ”€β”€ ...
β”œβ”€β”€ pages               #
β”‚   β”œβ”€β”€ api             # API endpoint
β”‚   β”œβ”€β”€ _app.tsx        # App component to initialize pages
β”‚   β”œβ”€β”€ _document.tsx   # Custom document to augment application's <html> and <body> tags
β”‚   └── ...
└── ...

Public

Next.js can serve static files, like images, under a folder called public in the root directory.

.
β”œβ”€β”€ ...
β”œβ”€β”€ public              #
β”‚   β”œβ”€β”€ favicons        #
β”‚   └── ...
└── ...

Styles

Css, theme configuration files are placed into this folder.

.
β”œβ”€β”€ ...
β”œβ”€β”€ styles              #
β”‚   β”œβ”€β”€ theme.tsx       #
β”‚   └── ...
└── ...

Api

Api call related functions.

Components

Components are independent and reusable bits of code.

.
β”œβ”€β”€ ...
β”œβ”€β”€ components          #
β”‚ β”œβ”€β”€ icons             #
β”‚ β”œβ”€β”€ atoms             #
β”‚ β”œβ”€β”€ molecules         #
β”‚ β”œβ”€β”€ organisms         #
β”‚ └── templates         #
└── ...

Context

Context provides a way to pass data through the component tree without having to pass props down manually at every level. (just like redux)

.
β”œβ”€β”€ ...
β”œβ”€β”€ context             #
β”‚   β”œβ”€β”€ auth            #
β”‚   └── ...
└── ...

Hooks

Custom hook allows you to extract some components logic into a reusable function that starts with use and that call can other hooks.

.
β”œβ”€β”€ ...
β”œβ”€β”€ hooks                #
β”‚   β”œβ”€β”€ useScript.tsx    #
β”‚   └── ...
└── ...

Utils

Small snippets you can use throughout the application. Short and specific functions and constants used throughout application.

Libs

Libraries you can use throughout the application. A library is a JavaScript file that contains a bunch of functions, and those functions accomplish some specific purpose.

.
β”œβ”€β”€ ...
β”œβ”€β”€ libs                  #
β”‚   β”œβ”€β”€ gtm.ts            #
β”‚   └── ...
└── ...

Cypress

Automated tests with cypress.

.
β”œβ”€β”€ ...
β”œβ”€β”€ cypess                #
β”‚ β”œβ”€β”€ fixtures            # Fixed data sets
β”‚ β”œβ”€β”€ integration         # End-to-end, integration tests (alternatively `e2e`)
β”‚ β”œβ”€β”€ plugins             #
β”‚ β”œβ”€β”€ support             #
└── ...

πŸ“› Naming

πŸ‘¨β€πŸ¦³ React Component

  • Extensions: Use .tsx extension for React components.

  • Filename: Use PascalCase for filenames. E.g., ReservationCard.tsx.

  • Reference Naming: Use PascalCase for React components and camelCase for their instances.

    // bad
    import reservationCard from './ReservationCard';
    
    // good
    import ReservationCard from './ReservationCard';
    
    // bad
    const ReservationItem = <ReservationCard />;
    
    // good
    const reservationItem = <ReservationCard />;
  • Component Naming: Use the filename as the component name. For example, ReservationCard.tsx should have a reference name of ReservationCard. However, for root components of a directory, use index.tsx as the filename and use the directory name as the component name:

    // bad
    import Footer from './Footer/Footer';
    
    // bad
    import Footer from './Footer/index';
    
    // good
    import Footer from './Footer';

πŸͺ Others

Always use camelCase for others.

  • scripts
  • folders
  • variables
  • functions

⭐️ Stack

  • Framework: Next.js
  • State Management: React Query, Context API
  • Styling: Chakra-ui, Emotion
  • Forms: React Hook Form
  • Testing: Cypress

Reference

next.js-starter's People

Contributors

hokyunrhee avatar

Stargazers

Roman avatar  avatar SJO avatar Jun avatar hyunsungK avatar

Watchers

 avatar

Forkers

endeavor5

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.