Best practices on using Next.js in a TypeScript monorepo
- Using
Turborepo
- Integrated internationalization with
next-intl
. - Integrated package manager
[email protected]
- Configure the behavior of turbo by adding a
turbo.json
file in your Workspace's root directory turbo - Using next.js
app-router
- Integrated
tailwindcss
- Integrated
eslint V9
- Integrated
hyperse next-env
for auto customized environment over next.js - Integrated
zod
- Integrated
@svgr/webpack
allow directly import.svg
ascomponent
- Integrated
vitest
for unitest also supporttspath alias
- Integrated
husky
for commit hook - Integrated
lint-staged
for commit hook - Integrated
git cz
- Integrated
changesets
- Integrated
commitlint
- Integrated
code-inspector-plugin
([shift + ⌥option]
) to resolvepage/component's
code is located.
- tsconfig.json (vitest, eslint)
- tsconfig.dev.json
yarn dev
- tsconfig.build.json
yarn build
the paths
tsconfig.json also can be resolved for apps/*
, we should avoid to use ts paths
alias to write code for mono-module
like core
utils
we can usealias
core
we should not usealias
If you are looking for single repo next.js best practices starter please see below link
https://github.com/hyperse-io/next.js-turborepo-starter
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:
cd my-turborepo
npx 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:
npx turbo link
Learn more about the power of Turborepo:
Multi Zones are an approach to micro-frontends that separate a single large application on a domain into smaller applications that each serve a set of paths.