This repository contains monorepo boilerplate written in Next.js. Used together with backend API part — laravel-starter-tpl.
This turborepo uses pnpm as a package manager. It includes the following packages/apps:
docs
: a Nextra application generated from Nextra: Docs Starter Kitweb
: Next.js appui
: a stub React component library shared by bothweb
anddocs
applicationseslint-config-custom
:eslint
configurations (includeseslint-config-next
andeslint-config-prettier
)tsconfig-config
:tsconfig
configs used throughout the monorepojest-config
: JestJS configs used across the monorepo- Each package/app is 100% TypeScript.
This repository has some additional tools already setup for you:
- Supporting NextJS 13.1.1+
- TypeScript support for static type checking
- Strict Mode for TypeScript and React 18
- ESLint for code linting and configured presets: NextJS Recommended, NextJS Core Web Vitals and Airbnb Style Guide
- Code formatting with Prettier
- Integrated with Tailwind CSS
- PostCSS for processing Tailwind CSS and CSSNANO for CSS optimization on production systems
- Husky for modern native git hooks
- Lint-staged for running linters on Git staged files
- GitHub Actions support out of the box
- SEO metadata, JSON-LD and Open Graph tags with Next SEO
- Sitemap support using next-sitemap
- Bundler Analyzer — Visualize size of webpack output files with an interactive zoomable treemap
- Optimized Lighthouse performance score
- End-2-end testing with cypress and JestJS support for writing unit tests
- Package auto-update in all workspace projects using npm-check-updates
- Keep package.json sorted using sort-package-json
- Client and server side error reporting supported by @sentry/nextjs
- macOS Monterey+ or Linux
- Docker 20.10 or newer
- Cloned, configured and running docker-shared-services, to support system wide DNS, Routing and TLS support via Traefik.
Warning: Repository with docker-shared-services should be configured, up and running, to ensure system wide TLS and DNS support.
-
First, setup, for this repository, compatible backend by following instructions in laravel-starter-tpl
-
After backend is set up done, clone this repository:
[email protected]:wayofdev/next-starter-tpl.git
-
Create
.env
file:$ make env \ APP_NAME=tpl \ SYSTEM_SERVICES_NAMESPACE=ss \ PROJECT_SERVICES_NAMESPACE=wod
-
Build, install and run application:
make
-
Now, project is running, and, if default settings were used, available at https://tpl.wod.docker
To build all apps and packages, run the following command:
# with makefile, through Docker
$ make build
# or, directly, without docker, using system binaries
$ pnpm run build
To develop all apps and packages, run the following command:
# with makefile, through Docker
$ make up
# or, directly, without docker, using system binaries
$ pnpm run dev
Turborepo can use a technique known as Remote Caching to share cache artifacts across machines, enabling you to share build caches with your team and CI/CD pipelines.
By default, Turborepo will cache locally. To enable Remote Caching you will need an account with Vercel. If you don't have an account you can create one, then enter the following commands:
# with makefile
$ make turbo-login
# directly
$ pnpm dlx turbo login
This will authenticate the Turborepo CLI with your Vercel account.
Next, you can link your Turborepo to your Remote Cache by running the following command from the root of your turborepo:
# with makefile
$ make turbo-link
# directly
$ pnpm dlx turbo link
You can check Makefile
or package.json
to get full list of commands for local testing. For testing, you can use these commands to test:
make test
Based on nextjs-monorepo-example template from belgattitude.
- Check his benchmark on package managers — belgattitude/compare-package-managers
Learn more about the power of Turborepo:
Other monorepo templates:
- waldronmatt/pnpm-turborepo-auto-boilerplate — a monorepo boilerplate using pnpm, turborepo, and auto.
- mkosir/turborepo-boilerplate — frontend turborepo boilerplate
- vercel/turbo — turborepo examples from Vercel
- nextauthjs/next-auth — Authentication package, built as monorepo; real life example
Other projects:
- ixartz/next-js-boilerplate
- Lots of latest examples for NextJS from Vercel
This repository was created in 2022 by lotyp / wayofdev.