dccxx-s3-explorer

1.0.19 • Public • Published

Vite React Boilerplate

Everything you need to kick off your next Vite + React web app!

Table of Contents

Overview

Built with type safety, scalability, and developer experience in mind. A batteries included Vite + React template.

  • 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
  • Vite - Feature rich and highly optimized frontend tooling with TypeScript support out of the box
  • React - A modern front-end JavaScript library for building user interfaces based on components
  • Tailwind CSS - A utility-first CSS framework packed with classes to build any web design imaginable
  • Storybook - A frontend workshop for building UI components and pages in isolation
  • TanStack Router - Fully typesafe, modern and scalable routing for React applications
  • TanStack Query - Declarative, always-up-to-date auto-managed queries and mutations
  • TanStack Table - Headless UI for building powerful tables & datagrids
  • 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
  • React Testing Library - A very light-weight, best practice first, solution for testing React components
  • Vitest - A blazing fast unit test framework powered by Vite
  • Playwright - Enables reliable end-to-end testing for modern web apps
  • Nivo - A rich set of data visualization components, built on top of D3 and React
  • react-i18next - A powerful internationalization framework for React/React Native based on i18next
  • Faker - Generate massive amounts of fake (but realistic) data for testing and development
  • Dayjs - A minimalist JavaScript library that parses, validates, manipulates, and displays dates and times for modern browsers
  • 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
  • Docker - Containerization tool for deploying your vite-react-boilerplate app

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

If you'd like to use the included Dockerfile then Docker is required as well:

Getting Started

Getting started is a simple as cloning the repository

git clone git@github.com:RicardoValdovinos/vite-react-boilerplate.git

Changing into the new directory

cd vite-react-boilerplate

Removing the .git folder (and any additional files, folders or dependencies you may not need)

rm -rf .git

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!

If you'd rather run the commands above in one go, check out the command below:

git clone git@github.com:RicardoValdovinos/vite-react-boilerplate.git &&\
cd vite-react-boilerplate &&\
rm -rf .git &&\
pnpm install &&\
pnpm run setup

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 Note section for crucial details regarding this package. Specifically, point 3.

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 -p 8080:80 todo-app

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.

TanStack Table Devtools Documentation is, at the time of writing this, non-existent. Having said that, usage is similar to the other TanStack devtools. A utility component restricting the devtools to development builds has been provided. The difference in comparison to the other TanStack devtools is the lack of floating mode. Instead, the Devtools are rendered as a component within the actual TanStack Table you define. An additional caveat being that the DevTools component (built-in and provided utility alike) require a table prop from the useReactTable() hook. In other words, if you have multiple tables, each table must have its own Devtools component. Check the simplified code below.

function Table(): FunctionComponent {
  /* some code */

  const table = useReactTable({
    data,
    columns,
    getCoreRowModel: getCoreRowModel(),
  });

  return (
    <>
      {/* table code */}
      <TanStackTableDevelopmentTools table={table} />
    </>
  )
}

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

Data Visualization

Testing

Development Tools

Git

Other

Package Sidebar

Install

npm i dccxx-s3-explorer

Weekly Downloads

585

Version

1.0.19

License

MIT

Unpacked Size

3.82 MB

Total Files

11

Last publish

Collaborators

  • dccxx