# Nextra

# Introduction

A monorepo is a single repository containing multiple distinct projects , with well-defined relationships between them. One of the main reasons for using a monorepo is to have a single source of truth for all projects. This means that all projects can be kept in sync and changes can be made across all projects in a single commit. When working in JavaScript and Node.js projects, monorepos are often used to manage multiple packages that are published to npm. This is the case of Nextra.

You can see that is a monorepo for the presence of a packages directory in the root of the project containing three npm related packages:

➜  nextra git:(casiano) ✗ tree -L 1 packages
packages
├── nextra
├── nextra-theme-blog
└── nextra-theme-docs
1
2
3
4
5

Also you can see in the package.json that the project depends on changesets (opens new window) (which is also a monorepo!). Changesets is a concept that hold two bits of information: a version type (following semver (opens new window)), and change information to be added to a changelog. In a monorepo context, changesets will handle bumping dependencies of changed packages.

There is a configuration file .changeset/config.json that specifies the packages that are part of the monorepo:

➜  nextra git:(casiano) ✗ cat .changeset/config.json 
{
  "$schema": "https://unpkg.com/@changesets/config@2.0.1/schema.json",
  "changelog": "@changesets/cli/changelog",
  "commit": false,
  "fixed": [["nextra", "nextra-theme-docs", "nextra-theme-blog"]],
  "linked": [],
  "access": "public",
  "baseBranch": "main",
  "updateInternalDependencies": "patch",
  "___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
    "onlyUpdatePeerDependentsWhenOutOfRange": true
  },
  "ignore": ["example-blog", "example-docs", "swr-site", "docs"]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

The overall changeset cycle after initialization should lead is a loop that looks like:

  1. Changesets added along with each change
  2. The version command is run when a release is ready, and the changes are verified
  3. The publish command is run afterwards.

See the dictionary (opens new window).

# Nextra Monorepo

# Introduction to React

See the section Introduction to React.

# Examples of Nextra Sites

See section Examples of Nextra Sites.

Last Updated: 18 days ago