Next.jsViteReactStarter

ts-monorepo — Next.js Starter Template

By NiGhTTraX

A template project for setting up a TypeScript monorepo, focused on making the IDE's "Go to Definition" work after a fresh clone without a build, and providing integration examples for various tools.

Explore the design

Compare the page layouts and mobile experience. Open any screenshot for a closer look.

1 previews
Author preview
Author-provided previewTop of page

Preview provided in the project README.

One original preview is available. Open the full image to inspect the design.

Screenshots show visual appearance; interactive behavior may differ.

Recorded 2026-09-30View source

What stands out

A quick read of the recorded project description.

01

Makes the IDE's "Go to Definition" work after a fresh clone without a build

02

Provides clean build output for each package, avoiding mixing in artifacts from other packages

03

Distinguishes between two types of workspaces: packages (published to npm) and apps (executed directly)

04

Provides a separate build tsconfig.json for packages, resolving monorepo dependencies to node_modules

05

README covers integration examples for ts-node, Babel, webpack, jest, Vite, NextJS, NestJS, Storybook, and more

06

Uses pnpm by default, while explaining that it can be used with yarn workspaces, npm workspaces, or lerna bootstrap

Template Details

This template is organized around two goals for a TypeScript monorepo: first, making the IDE's "Go to Definition" work after a fresh clone without needing to build first; second, giving each package clean build output when published, without mixing in artifacts from other packages. The repository distinguishes between two types of workspaces: packages (published to npm and installed) and apps (executed directly), and provides a separate build tsconfig.json for packages that resolves monorepo dependencies to node_modules.

The template uses pnpm by default, while also explaining that it can be used with yarn workspaces, npm 7+ workspaces, or npm < 7 plus lerna bootstrap, and recommends pnpm to avoid dependency issues caused by hoisting. The README provides path alias resolution configuration examples for ts-node, Babel, webpack, jest, Vite, NextJS, NestJS, Storybook, and the no-longer-supported create-react-app, and links to two related blog posts; for a project references approach, see the project-references branch.

To use it, click Use this template on the GitHub page, then remove examples as needed and add the tools you need; compilation target, module system, tree shaking, and similar choices are left to the user.

Next.jsViteReactLauncher

Is it right for your project?

Use Cases

  • You want to use IDE go-to-definition directly after cloning the repository, without building the entire project first
  • You need to publish multiple packages to npm and give each package independent, clean build output
  • You maintain both publishable packages and directly runnable apps in the same repository
  • You need to configure TypeScript path aliases for tools such as ts-node, Babel, webpack, jest, Vite, NextJS, NestJS, and Storybook
  • You want to refer to a project references approach and can switch to the project-references branch

Suitable For

  • Developers who need to set up a TypeScript monorepo and care about the IDE navigation experience
  • Teams that need to distinguish between publishable packages and executable apps as two types of workspaces
  • Projects using pnpm, yarn workspaces, or npm workspaces to manage a multi-package repository
  • Projects that need to handle path aliases consistently across multiple build and test tools

Getting started & customization

Use these recorded setup notes alongside the repository instructions for your chosen version.

  1. 1

    Click Use this template on the GitHub page to create your own repository

  2. 2

    pnpm is used by default: install pnpm first, then run pnpm i to install all dependencies

  3. 3

    You can also switch to yarn workspaces, npm 7+ workspaces, or npm < 7 plus lerna bootstrap

  4. 4

    Remove unneeded examples as necessary and add the tools you need

  5. 5

    Compilation target, module system, tree shaking, and similar choices are left to the user

Read repository instructions

License & source material

Usage conditions & limitations

Free to use · keep license notice

This entry covers the free version under the MIT license in the public repository; the free scope is the code of that version and does not mean that external services or third-party assets are free.

Must comply with when using

  • You may use, modify, commercialize, and distribute the code of this version for free.
  • When distributing copies or substantial portions of the code, retain the original author's copyright notice and the full MIT license notice.
  • The code is provided as is; warranties and limitations of liability are governed by the original license and applicable law.

Additional costs & items to verify

  • The create-react-app integration is no longer supported; the README explicitly marks this approach as unavailable, and users should not rely on this integration.
  • The author strongly recommends using pnpm and notes that other package managers may cause dependency issues due to hoisting; this is usage advice, not a mandatory restriction.
  • Configuration such as compilation target, module system, and tree shaking must be decided by the user; the template does not provide these presets.
  • Demo images, fonts, icons, and other third-party assets must be checked against their respective licenses and cannot be judged solely by the code's MIT license.
  • External services such as domains, hosting, databases, payments, or AI may incur separate charges.
View Original Text Basis

Permission is hereby granted, free of charge

Original License Text

Note: this is not supported anymore.

Original README

I strongly recommend `pnpm`, not only because it's usually faster, but because it avoids dependency problems caused by hoisting

Original README

Compilation targets, module systems, tree shaking etc. are left up to you to decide.

Original README
https://github.com/NiGhTTraX/ts-monorepo/blob/master/LICENSEhttps://github.com/NiGhTTraX/ts-monorepo/blob/master/README.md

Compiled by DeepSeek based on repository license and README ·2026-09-30. Results only cover the materials read; dependencies, images, fonts, and subsequent term changes are subject to their respective original texts.

Project checks & description sources

Template Information

Source platforms
GitHub
Documentation and maintenance reference score
More documented · 88 / 100
Technologies
Next.js · Vite · React
Website type
Starter
How this score is calculated

Our heuristic uses license records (up to 30), a demo link (12), a preview (10), stars (15), recorded maintenance (15), description completeness (8), feature records (5) and classification data (5). It is not a code, security or performance test, or a Google score. A link does not establish tested functionality.

What to verify for this project

Repository update recorded
2026-09-30
Screenshot last checked
2026-09-30

No demo link is recorded. Use the repository instructions to evaluate the project locally; the screenshot alone cannot establish interactive behavior.

The catalog identifies Next.js as the primary stack. Check the actual dependency manifest and lockfile for versions and hosting requirements. These notes use recorded metadata, not a code audit or a deployment test.

Use a selection guide →

How this description was prepared

AI-assisted description based on catalog records and repository material. Repository authors are not automatically the reviewers of this description.

Automatically checked against source and license rules; no manual editorial review.

Inspect the recorded source material

SHA-256: 1baf9405c241f3e54ee26b038c49404f6e508ad971896c1d86826a367551e850

2026-09-30T07:58:15.594Z

Source file / repository
<!--suppress HtmlDeprecatedAttribute -->
<div align="center">

![](media/monorepo.png)

Template project for setting up a TypeScript monorepo

[![tests](https://github.com/NiGhTTraX/ts-monorepo/actions/workflows/tests.yml/badge.svg)](https://github.com/NiGhTTraX/ts-monorepo/actions/workflows/tests.yml)

</div>

----

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of content**

- [Features](#features)
- [Setup](#setup)
- [Docs](#docs)
- [Packages vs apps](#packages-vs-apps)
- [Integrations](#integrations)
  - [ts-node](#ts-node)
  - [Babel](#babel)
  - [webpack](#webpack)
  - [jest](#jest)
  - [Vite](#vite)
  - [NextJS](#nextjs)
  - [NestJS](#nestjs)
  - [Storybook](#storybook)
  - [create-react-app](#create-react-app)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## Features

> The main focus of this repo is making the **`Go to definition`** feature in IDEs work without any surprises, meaning it will work after a fresh clone without needing to build the project.

![find-usage](./media/find-usage.gif)

> The secondary focus is to remove surprises when **publishing** packages. The repo is set up so that each package gets a clean build output without any artifacts from other packages.

![build-output](./media/build-output.png)

## Setup

Click the `Use this template` button at the top of the GitHub page.

This repo uses [pnpm](https://pnpm.io/), but should work fine with any of the following:

- [yarn workspaces](https://classic.yarnpkg.com/en/docs/workspaces/)
- [npm 7+ workspaces](https://docs.npmjs.com/cli/v7/using-npm/workspaces)
- [npm < 7 and `lerna bootstrap`](https://github.com/lerna/lerna/blob/main/commands/bootstrap/README.md)

I strongly recommend `pnpm`, not only because it's usually faster, but because it avoids dependency problems caused by hoisting (see https://github.com/NiGhTTraX/ts-monorepo/commit/d93139166b25fab15e9538df58a7d06270b846c9 as an example).

```sh
# Install pnpm with your preferred method: https://pnpm.io/installation.
npm i -g pnpm

# Install all dependencies.
pnpm i
```

Then customize the template to your own needs, removing examples you don't need, and adding the tools you do need. Compilation targets, module systems, tree shaking etc. are left up to you to decide.

## Docs

See the following blog posts:

- [How to set up a TypeScript monorepo and make Go to definition work](https://medium.com/@NiGhTTraX/how-to-set-up-a-typescript-monorepo-with-lerna-c6acda7d4559)
- [Making TypeScript monorepos play nice with other tools](https://medium.com/@NiGhTTraX/making-typescript-monorepos-play-nice-with-other-tools-a8d197fdc680)

If you're looking for the project references solution checkout the [`project-references`](https://github.com/NiGhTTraX/ts-monorepo/tree/project-references) branch.

## Packages vs apps

This repo contains two types of workspaces:

- `packages`: meant to be published to npm and installed,
- `apps`: meant to be executed.

A good example to illustrate the difference is `create-react-app`: you wouldn't publish an app like this to npm, you would run it, more specifically you would build the JS bundle and then deploy that somewhere.

For packages, you don't want to bundle all the monorepo dependencies, and instead publish them individually. That's why packages have a separate build `tsconfig.json` that resolves monorepo dependencies to `node_modules`.

## Integrations

### ts-node

Use [tsconfig-paths](https://www.npmjs.com/package/tsconfig-paths) to resolve the path aliases at runtime:

```json
{
  "scripts": {
    "start": "ts-node -r tsconfig-paths/register src/index.ts"
  }
}
```

See the full example [here](apps/ts-node).

### Babel

Use [babel-plugin-module-resolver](https://www.npmjs.com/package/babel-plugin-module-resolver) to resolve the path aliases:

```js
module.exports = {
  presets: [
    ["@babel/preset-env", { targets: { node: "current" } }],
    "@babel/preset-typescript",
  ],

  plugins: [
    [
      "module-resolver",
      {
        alias: {
          "^@nighttrax/(.+)": "../\\1/src",
        },
      },
    ],
  ],
};
```

See the full example [here](apps/jest-babel).

### webpack

Use [tsconfig-paths-webpack-plugin](https://www.npmjs.com/package/tsconfig-paths-webpack-plugin) to resolve the path aliases:

```js
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");

module.exports = {
  resolve: {
    plugins: [new TsconfigPathsPlugin()]
  }
};
```

See the full example [here](apps/webpack).

### jest

If you use `Babel` then see [this example](apps/jest-babel) from the [Babel](#babel) section above.

If you use [ts-jest](https://github.com/kulshekhar/ts-jest) then you can use its `pathsToModuleNameMapper` helper: 

```js
const { pathsToModuleNameMapper } = require("ts-jest");
const { compilerOptions } = require("../../tsconfig.json");

module.exports = {
  preset: "ts-jest",

  moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
    // This has to match the baseUrl defined in tsconfig.json.
    prefix: "<rootDir>/../../",
  }),
};
```

See the full example [here](apps/jest-tsjest).

### Vite

Use [vite-tsconfig-paths](https://www.npmjs.com/package/vite-tsconfig-paths) in the Vite config:

```typescript
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import tsconfigPaths from "vite-tsconfig-paths";

export default defineConfig({
  plugins: [
    react(), 
    tsconfigPaths()
  ],
});
```

See full example [here](apps/vite).

### NextJS

Extend Next's webpack config to enable compiling packages from the monorepo:

```js
module.exports = {
  webpack: (config) => {
    // Let Babel compile outside of src/.
    const tsRule = config.module.rules.find(
      (rule) => rule.test && rule.test.toString().includes("tsx|ts")
    );
    tsRule.include = undefined;
    tsRule.exclude = /node_modules/;

    return config;
  },
};
```

See the full example [here](apps/nextjs).

### NestJS

Include the path aliases in both `tsconfig.json` and `tsconfig.build.json` and tell NestJS where to find the `main.js` file:

```json
{
  "collection": "@nestjs/schematics",
  "sourceRoot": "src",
  "entryFile": "apps/nestjs/src/main"
}
```

See the full example [here](apps/nestjs).

### Storybook

[Extend Storybook's webpack config](https://storybook.js.org/docs/react/builders/webpack#typescript-module-resolution) and apply the [tsconfig-paths-webpack-plugin](https://www.npmjs.com/package/tsconfig-paths-webpack-plugin):

```js
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');

module.exports = {
  webpackFinal: async (config) => {
    config.resolve.plugins = [
      ...(config.resolve.plugins || []),
      new TsconfigPathsPlugin({
        extensions: config.resolve.extensions,
      }),
    ];
    return config;
  },
};
```

See the full example [here](apps/storybook).

### create-react-app

> Note: this is not supported anymore.

Use [craco](https://www.npmjs.com/package/@craco/craco) or [react-app-rewired](https://www.npmjs.com/package/react-app-rewired) to extend CRA's webpack config and apply the [tsconfig-paths-webpack-plugin](https://www.npmjs.com/package/tsconfig-paths-webpack-plugin):

```js
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");

module.exports = (config) => {
  // Remove the ModuleScopePlugin which throws when we
  // try to import something outside of src/.
  config.resolve.plugins.pop();

  // Resolve the path aliases.
  config.resolve.plugins.push(new TsconfigPathsPlugin());

  // Let Babel compile outside of src/.
  const oneOfRule = config.module.rules.find((rule) => rule.oneOf);
    const tsRule = oneOfRule.oneOf.find((rule) =>
      rule.test.toString().includes("ts|tsx")
    );
  tsRule.include = undefined;
  tsRule.exclude = /node_modules/;

  return config;
};
```

See the full example [here](https://github.com/NiGhTTraX/ts-monorepo/tree/4222f84e1879a85ffd352fc33c4a8c5167225184/apps/cra). For tests, see the [jest example](#jest).
Report a correction

Explore similar templates

Compare previews and descriptions within the same stack and category.