# Templates

The templates pnpm create axle starts a new monorepo from.

[`axle create`](https://axlers.dev/docs/reference/create.md), behind `pnpm create axle`, starts a new monorepo from one of these templates. Each app in them is exactly what its framework's own tool creates with its default answers, so its docs apply unchanged.

| Template        | What's inside                                                                         | Plugins        |
| --------------- | ------------------------------------------------------------------------------------- | -------------- |
| `next-express`  | A Next.js app in `apps/web` and an Express API in `apps/api`                          | Next.js        |
| `react-express` | A React app on Vite in `apps/web` and an Express API in `apps/api`                    | Vite           |
| `next`          | A Next.js app with Tailwind CSS, from `create-next-app`                               | Next.js        |
| `react`         | A React app on Vite, in TypeScript, from `create-vite`                                | Vite           |
| `vue`           | A Vue app on Vite with Vue Router, Pinia and Vitest, from `create-vue`                | Vite, Vitest   |
| `nuxt`          | A Nuxt app, from `create-nuxt`                                                        | Nuxt           |
| `angular`       | An Angular app with Vitest, from the Angular CLI                                      | Angular        |
| `sveltekit`     | A SvelteKit app in TypeScript, from `sv create`                                       | SvelteKit      |
| `astro`         | An Astro site, from `create-astro`                                                    | Astro          |
| `react-router`  | A React Router app with server rendering and Tailwind CSS, from `create-react-router` | React Router   |
| `express`       | An Express API, from `express-generator`                                              |                |
| `nestjs`        | A NestJS API with Vitest, from the Nest CLI                                           | NestJS, Vitest |
| `expo`          | A React Native app with Expo Router, from `create-expo-app`                           | React Native   |
| `library`       | A TypeScript package built with tsdown and tested with Vitest, from `create-tsdown`   | tsdown, Vitest |
| `empty`         | Just the workspace, ready for your own packages                                       |                |

`express-generator` still writes Express 4.16, so the Express API's dependencies are raised to their current versions, and it gets a `dev` script that restarts it when a file changes.

## What every template has

- `apps/` for the apps, as the table says, and `packages/` for the libraries they share
- a root `package.json` whose `dev`, `build`, `lint`, `format` and `test` scripts run that task in every package through Axle, as far as the template's apps have them
- [config packages](#shared-settings) in `packages/` with the lint, format and TypeScript settings every project extends
- the workspace set up for your package manager
- an [`axle.toml`](https://axlers.dev/docs/reference/configuration.md) with the official [plugins](https://axlers.dev/docs/plugins.md) for the template's tools, added with checked hashes, and the `#:schema` line that lets your editor complete the rest
- a `.gitignore` and a `README.md` with the commands for your package manager

Start with the template's `dev` script, which runs every app's development server at once:

```sh
pnpm dev
```

## Shared settings

The settings every project shares live in config packages in `packages/`, which each project depends on and extends:

| Package                   | What it holds                                                                                                            |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `@repo/typescript-config` | `base.json`, the TypeScript options every project starts from, such as `strict`                                          |
| `@repo/oxlint-config`     | the [Oxlint](https://oxc.rs/docs/guide/usage/linter) rules and plugins                                                   |
| `@repo/eslint-config`     | the ESLint rules: JavaScript's and typescript-eslint's recommended ones, with the rules Oxlint already checks turned off |
| `@repo/prettier-config`   | the [Prettier](https://prettier.io) options                                                                              |

Which of them a monorepo has follows the linter and formatter [`axle create`](https://axlers.dev/docs/reference/create.md#the-questions) asked for. Oxfmt brings an `@repo/oxfmt-config` instead of Prettier's, and Biome a single `@repo/biome-config` that lints and formats.

A framework's own settings, such as ignoring SvelteKit's `.svelte-kit` folder, are a separate export of the same package, `@repo/eslint-config/svelte-kit`, that the app's config extends instead of the base one. The repository has one `.gitignore`, at the root, with what its apps ignore; each project's Prettier `format` script points at it with `--ignore-path`, since Prettier only reads the one in the folder it runs in.

Each project lists the ones it uses in `devDependencies`, as `"@repo/eslint-config": "workspace:*"`, and has its own small config file that extends them. A project adds its framework's rules there, or overrides a shared one. The Express API, for one, allows unused arguments in its `oxlint.config.mts`, since Express tells middleware apart by how many it takes:

```ts
import shared from '@repo/oxlint-config'
import { defineConfig } from 'oxlint'

export default defineConfig({
    extends: [shared],
    rules: {
        'no-unused-vars': ['error', { args: 'none' }],
    },
})
```

`@repo/eslint-config` also exports `@repo/eslint-config/javascript`, its settings without typescript-eslint's, for a framework that brings its own TypeScript rules, and `@repo/eslint-config/oxlint`, the rules Oxlint already checks turned off, to add last. The Next.js app takes both, since `eslint-config-next` already includes typescript-eslint.

Each project's `lint` and `format` scripts run its tools, and the root's run them in every project, from the cache when nothing changed. [`axle generate package`](https://axlers.dev/docs/reference/generate.md#new-packages) creates a package in `packages/` that extends the same config packages.

## Choosing one

Pass its name to skip the questions:

```sh
pnpm create axle my-shop --template next-express
```

To add an app later, [`axle generate app`](https://axlers.dev/docs/reference/generate.md#new-apps) runs its framework's own tool in `apps/` and links it to the config packages, or copies an app you already have:

```sh
axle generate app admin --with react
```

Then install, and Axle finds the new app on its next run.
