Code Monkey home page Code Monkey logo

nexstart's Introduction

Nexstart

Batteries included starter template for NextJS App Router. The below documentation includes tools that haven't been integrated yet.

Table of Contents

Overview

  • pnpm - A strict and efficient alternative to npm with up to 3x faster performance
  • TypeScript - A typed superset of JavaScript designed with large scale applications in mind
  • ESLint - Static code analysis to help find problems within a codebase
  • Prettier - An opinionated code formatter
  • NextJS - React framework for building full-stack web apps
  • shadcn + Radix UI + Tailwind CSS - Ultra flexible and re-usable components for building high-quality, accessible design systems and web apps
  • TanStack Query - Declarative, always-up-to-date auto-managed queries and mutations
  • Zustand - An unopinionated, small, fast and scalable bearbones state-management solution
  • React Hook Form - Performant, flexible and extensible forms with easy-to-use validation
  • Zod - TypeScript-first schema validation with static type inference
  • Husky + Commitizen + Commitlint - Git hooks and commit linting to ensure use of descriptive and practical commit messages
  • ts-reset - Improvements for TypeScripts built-in typings for use in applications

A more detailed list of the included packages can be found in the Installed Packages section. Packages not shown above include Devtools, ui helper libraries, and eslint plugins/configs.

Requirements

Getting Started

This is a template repository. See Github Creating a repository from a template

Installing dependencies

pnpm install

And running the setup script (initializes git repository and husky and installs playwright)

pnpm run setup

Congrats! You're ready to starting working on that new project!

Note: This project comes with two git hooks added by husky. A prepare-commit-msg hook to run the Commitizen cli for those nice commit messages and a commit-msg hook to run Commitlint on the message itself. Commitlint will ensure the commit message follows the Conventional Commits specification (it will if you used commitizen).

If you wish to remove any hooks, simply delete the corresponding file in the .husky directory.

Important Note

  1. This boilerplate project does not include a demo. At most, a few utilities (types, devtools, initial home page routes) are included. There is no glue to get in your way when trying to modify the template.

  2. Due to empty directories not being included in git commits, placeholder README files have been added to these empty directories. These README files contain simple descriptions about how the different directories in the accompanying folder structure may be used. As an example check out the recommended component organizational structure as well as the recommended folder structure.

  3. Faker is included to encourage more isolated testing and allow for rapid development of demos and MVPs. However, please make note that, due to a bug, importing Faker from the main package (without a locale) will result in the entire Faker lib being imported causing bundle sizes to increase up to 2+ MB. Instead prefer localized imports as shown below.

    // import { faker } from '@faker-js/faker';
    import { faker } from '@faker-js/faker/locale/en'; // prefer localization when possible
    

    The imported lib will instead be around 600 KB. Nonetheless, Faker should NOT be used in production and instead be limited to testing and demos.

Testing

Unit testing is handled by React Testing Library and Vitest while End-to-End (E2E) Testing is conducted by Playwright.

If you'd like to run all tests, Unit and E2E alike, execute the following command:

pnpm run test

Unit Testing

When running unit test scripts, it is assumed that unit tests will be colocated with the source files. Take a look at the placeholder README file in src/components for an example.

If you'd like to execute unit tests specifically, the below command will execute vitest:

pnpm run test:unit

If instead you are interested in coverage reporting, run:

pnpm run test:unit:coverage

All unit tests run in watch mode by default. If you'd like to disable watch mode, change the package.json test scripts with the following

before:

"scripts": {
  	"test:unit": "vitest src/",
	"test:unit:coverage": "vitest --coverage src/"
}

After:

"scripts": {
  	"test:unit": "vitest run src/",
	"test:unit:coverage": "vitest run --coverage src/"
}

Note: Faker is included to provide mock data. See the Important Notes section for crucial details regarding this package. Specifically, point 4.

End-to-End (E2E) Testing

Running E2E tests use a similar syntax to running unit tests:

pnpm run test:e2e

If you wish to see the reports, run:

pnpm run test:e2e:report

Preparing for Deployment

Instructions are provided for deploying both with and without Docker. Both options still require a platform to host the application.

Without Docker

Deploying is as easy as running

pnpm run build

and pointing your web server to the generated index.html file found at dist/index.html

With Docker

A Dockerfile with an NGINX base image is also provided for quick and easy deployments. Simply execute the following commands:

  1. pnpm run build
  2. docker build . -t <container_name>
    • Example: docker build . -t todo-app
  3. docker run -p <port_number>:80 <container_name>
    • Example: docker run todo-app -p 8080:80

Continuous Integration

Due to the vast array of tools, opinions, requirements and preferences a CI template is not included in this project.

Devtools

This project includes a set of Devtools. Some are additional package dependencies whereas others come built-in to the packages themselves.

Devtool dependencies:

A set of utility components are provided in src/components/utils/development-tools/. These wrapper components check whether the application is running in development or production mode and render the component or null respectively. In other words, you can confidently use them during development without having to worry about them showing up for end users in production.

TanStack Query Devtools are ready to go out of the box. The development vs. production rendering mechanism is built into the devtools. If you do wish to render the devtools in production you can freely do so by following the TanStack Query Devtools documentation. The devtools component can be found in src/App.tsx.

When running the application in development mode you can find the TanStack Query Devtools icon in the bottom left corner of the page sporting the React Query Logo.

TanStack Router Devtools, however, utilizes its respective utility component in this project. The initial setup has been taken care of but if you wish to modify or remove the component, have a look in src/App.tsx.

The TanStack Router Devtools icon can be found in the bottom right corner of the page denoted by the vertically stacked "TANSTACK ROUTER" logo.

The above components, along with their imports, are commented out to start.

React Hook Form DevTools icon can be recognized in the top right corner of the page by the pink React Hook Form clipboard logo. A utility component has also provided. Like the TanStack Table Devtools component above, a prop must be passed from a specific hook. In this case, it is the control prop from the useForm() hook. Similar to TanStack Table, use of React Hook Form DevTools requires the component be added to each unique form. More information can be found in the React Hook Form DevTools documentation.

To reiterate, if you wish to restrict the Devtools to development builds use the provided components found at src/components/utils/development-tools instead of the built-in components from their respective modules.

Built-in Devtools:

  • Zustand

Zustand provides a built-in devtools middleware for use with Redux DevTools.

Installed Packages

A simplified list can be found in the Overview section.

Base

Routing

Linting & Formatting

State Management

UI

Forms

Testing

Development Tools

Git

Other

nexstart's People

Contributors

lushiyun avatar

Watchers

 avatar

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.