---
title: Creating an app
description: Scaffold a new Angular app on vite-plugin-ngp with npm, pnpm, yarn or bun create, choose a template, and know what each file it writes is for.
---

# Creating an app

This page is for starting a new Angular app on Vite. If you already have an Angular app, [Getting started](getting-started) moves it instead.

`@push-based/create-ngp` writes the app and stops. It doesn't install anything or run `git init`, and it changes nothing outside the directory you give it. What it writes is the app Getting started describes, with routing, a spec and `ng new`'s size budgets, and optionally server rendering with `@angular/ssr`. It can also put that app in a monorepo, next to a library.

## Run it

Use the package manager you want the app to use. The scaffolder reads which one started it and prints that one's commands at the end:

| Package manager | Command | Then |
|---|---|---|
| npm | `npm create @push-based/ngp@latest` | `npm install`, `npm run dev` |
| pnpm | `pnpm create @push-based/ngp` | `pnpm install`, `pnpm dev` |
| Yarn | `yarn create @push-based/ngp` | `yarn install`, `yarn dev` |
| bun | `bun create @push-based/ngp` | `bun install`, `bun dev` |
| [Vite+](vite-plus#create-a-new-app) | `vp create @push-based/ngp` | `vp dev`: vp installs for you |

Each command expands `@push-based/ngp` to `@push-based/create-ngp` and runs it from npm. You need Node 26 or later, for the scaffolder and the plugin alike. The app then runs where the plugin does: macOS, or Linux with glibc, natively, and anywhere else with [`engine: 'wasm'`](configuration#engine).

It asks three questions, the directory, the template and the layout, writes the app, and prints the commands in the last column: `cd` into the app, install, start the dev server.

## Options

Anything you pass on the command line isn't asked:

```bash
npm create @push-based/ngp@latest -- shop --template app-ssr
```

With npm, put the scaffolder's options after `--`, or npm takes them for its own. pnpm, Yarn and bun pass them on without it: `pnpm create @push-based/ngp shop --template app-ssr`. Under Vite+, the options also go after `--`, and [Using Vite+](vite-plus#pass-the-directory-and-the-template) has a catch about `--no-interactive`.

| Option | What it does |
|---|---|
| `[directory]` | Where to write the app, created if it doesn't exist. Asked for when missing; `ngp-app` without a prompt. `.` writes into the directory you're in |
| `-t, --template <name>` | `app` or `app-ssr`, as [below](creating-an-app#the-templates). Asked for when missing; `app` without a prompt. An unknown name stops the scaffolder before it writes or deletes anything |
| `--monorepo`, `--no-monorepo` | Put the app in `apps/web` of a monorepo, next to a library in `libs/ui`, as [below](creating-an-app#the-monorepo-layout), or write a single app. Asked for when missing; a single app without a prompt. Works with either template |
| `--overwrite` | Empty a directory that isn't empty, without asking. Without it the scaffolder asks, and when it can't ask, it stops. A `.git` folder is kept either way, and doesn't count as content |
| `--interactive`, `--no-interactive` | Whether to ask. The default is to ask when stdin is a terminal, so a CI job never waits on a prompt |
| `-h, --help` | Print the options and the templates |

Because `.git` doesn't count, you can start from a repository you've already made:

```bash
git init shop && cd shop
```

```bash
npm create @push-based/ngp@latest -- . --template app
```

The package name comes from the directory's last segment. It's lowercased, spaces become dashes, and characters npm doesn't allow in a name become dashes too: `apps/Admin Panel` gives `admin-panel`, and `.` names the app after the directory you're in.

## What the scaffolder changes

It copies the template and changes four things in it: the `name` in `package.json`, the plugin's version in `package.json`, the `<title>` in `index.html`, and the heading of `README.md`. Two files are stored under other names and renamed on the way: `_gitignore` becomes `.gitignore`, because npm drops a published `.gitignore`, and `_yarnrc.yml` becomes `.yarnrc.yml` the same way, so no package manager's packer can leave it out. Nothing else in the template is generated, so what you read in the [templates' folder](https://github.com/push-based/vite-plugin-ngp/tree/main/packages/create-ngp/templates) is what you get.

The plugin's version is the scaffolder's own. The two packages are released together, at the same version, so `create-ngp` 0.4.3 writes `@push-based/vite-plugin-ngp` 0.4.3. Every `@angular/*` package of the framework is pinned to the release the plugin's ngp build was made from, `22.3.2` today. `app-ssr` pins `@angular/ssr` to `22.3.0`, and that isn't a mistake: the Angular CLI releases `@angular/ssr`, it doesn't publish every framework patch, and `22.3.0` is its newest 22.3 release. Every version is exact: nothing moves until you move it.

## The templates

Both are `ng new`'s app on Vite: standalone components, zoneless change detection, strict templates, one lazy route, `ng new`'s three tsconfig files, and its two size budgets. They leave out what only the Angular CLI reads: `angular.json`, `.editorconfig` and `.vscode/`.

| | `app` | `app-ssr` |
|---|---|---|
| Renders | In the browser | On the server, then hydrates in the browser, replaying clicks made before it did |
| `vite.config.ts` | `ngp({ budgets })` | `ngp({ ssr: true, budgets })` |
| Scripts | `dev`, `build`, `preview`, `test` | `dev`, `build`, `start`, `test` |
| `vite build` writes | `dist/`, a static site | `dist/client` and `dist/server`, with every route prerendered |
| Spec | `src/app/app.spec.ts`, under Vitest in Node on Domino | The same |

Pick `app-ssr` if you think you'll want server rendering. Adding `@angular/ssr` to an `app` later means writing the four files below and adding its packages by hand, as [Server rendering](server-rendering#with-angular-ssr) describes. The one thing `app-ssr` can't do yet is [i18n](i18n): with `@angular/ssr`, the `i18n` option stops the build.

### The files in `app`

```text
shop/
├── .gitignore
├── .yarnrc.yml
├── README.md
├── index.html
├── package.json
├── pnpm-workspace.yaml
├── public/
│   └── favicon.svg
├── src/
│   ├── main.ts
│   ├── styles.css
│   ├── test-setup.ts
│   └── app/
│       ├── app.config.ts
│       ├── app.css
│       ├── app.html
│       ├── app.routes.ts
│       ├── app.spec.ts
│       ├── app.ts
│       └── home.ts
├── tsconfig.json
├── tsconfig.app.json
├── tsconfig.spec.json
├── vite.config.ts
└── vitest.config.ts
```

| File | What it's for |
|---|---|
| `index.html` | Where Vite starts, in place of `angular.json`. It links `src/styles.css`, your global stylesheet, and loads `src/main.ts` |
| `public/` | Copied as it is into the build, as with `ng new` |
| `src/main.ts` | Bootstraps the app, as `ng new` writes it. It doesn't import `@angular/compiler`: the plugin links Angular's libraries ahead of time |
| `src/app/app.ts`, `app.html`, `app.css` | The root component, with an external template and stylesheet. Edit `app.html` with the dev server running and the page updates without a reload |
| `src/app/home.ts` | The one route, loaded lazily, with an inline template |
| `src/app/app.routes.ts`, `app.config.ts` | Routes and providers, as `ng new` writes them |
| `src/app/app.spec.ts` | One spec, run with TestBed under Vitest |
| `src/test-setup.ts` | Starts TestBed on the server platform, on Domino's DOM, and resets it after every test. [Testing with Vitest](testing#setup-node-on-the-server-platform) explains why, and has the jsdom and browser-mode setups |
| `tsconfig.json` | Compiler options and `angularCompilerOptions`, with `strictTemplates` on. The other two extend it |
| `tsconfig.app.json` | What the plugin reads in the dev server and `vite build`. It leaves out specs and the setup file |
| `tsconfig.spec.json` | What the plugin reads under Vitest, which looks for it first |
| `vite.config.ts` | The plugin, with `ng new`'s budgets: a warning at 500 kB of initial JavaScript and an error at 1 MB, and 4 kB and 8 kB for any component stylesheet |
| `vitest.config.ts` | Vitest reads this file instead of `vite.config.ts`, so it has its own `ngp()`. An option you add to `vite.config.ts` doesn't reach your specs unless you add it here too |
| `pnpm-workspace.yaml` | Read by pnpm only. It denies esbuild's install script, which the plugin doesn't need and pnpm 11 and later stop the install over |
| `.yarnrc.yml` | Read by Yarn 2 and later only. It sets `nodeLinker: node-modules`, because the plugin [can't run](status#what-doesnt-work-yet) under Plug'n'Play |

Delete `pnpm-workspace.yaml` and `.yarnrc.yml` if you don't use pnpm or Yarn.

Three dependencies look out of place. `@angular/platform-server` is a dev dependency of the browser-only `app` because the spec runs on its DOM. `@angular/platform-browser-dynamic` is there because `ServerTestingModule` imports it, and npm's deprecation notice for it is Angular's. And `typescript` is 6.0, the version `@angular/compiler-cli` runs on: the [type-check](type-checking) uses TypeScript 7, which the plugin installs for itself.

### What `app-ssr` adds

`app-ssr` is `app` with the files `ng new --ssr` writes, laid out the same way:

| File | What it's for |
|---|---|
| `src/server.ts` | The Express server: static files from `dist/client`, then `AngularNodeAppEngine` for every page. Add API routes here; the dev server sends requests through it too, so they work in `npm run dev` |
| `src/main.server.ts` | Bootstraps the app on the server |
| `src/app/app.config.server.ts` | The server's providers, merged over `app.config.ts` |
| `src/app/app.routes.server.ts` | How each route renders: `Prerender` at build time, `Server` on each request, or `Client` in the browser. Every route starts as `Prerender` |

It also changes four of `app`'s files. `vite.config.ts` sets `ssr: true`. `app.config.ts` adds `provideClientHydration(withEventReplay())`. `package.json` adds `@angular/ssr` and `express`, moves `@angular/platform-server` into `dependencies`, and runs the built server with `npm start` in place of `preview`, because `vite preview` serves files and doesn't run `server.ts`. Both tsconfigs list `types: ["node"]`, for `server.ts`.

The built server answers only for `localhost`. Before you deploy, list your hosts in [`ssr.allowedHosts`](configuration#ssr-allowedhosts), or in `NG_ALLOWED_HOSTS` when the server starts. [Server rendering](server-rendering#with-angular-ssr) has the rest.

## The monorepo layout

With `--monorepo`, the template you picked becomes `apps/web`, and a library sits next to it in `libs/ui`. It's the layout of an Nx workspace without Nx: one `package.json` at the top for every app and library, path aliases in `tsconfig.base.json`, and each library compiled from source as part of the app that imports it. Pick it if you expect more than one app, or code you want to keep apart from the app, from the start. Moving a single app into it later means moving its files by hand.

```text
shop/
├── package.json
├── pnpm-workspace.yaml
├── tsconfig.base.json
├── vitest.config.ts
├── apps/
│   └── web/           the app template, minus the files that moved to the top
│       ├── index.html
│       ├── src/
│       ├── tsconfig.json
│       ├── tsconfig.app.json
│       ├── tsconfig.spec.json
│       ├── vite.config.ts
│       └── vitest.config.ts
└── libs/
    └── ui/
        ├── src/
        │   ├── index.ts
        │   ├── test-setup.ts
        │   └── lib/ui/ui.ts, ui.html, ui.css, ui.spec.ts
        ├── tsconfig.json
        └── vitest.config.ts
```

`.gitignore`, `.yarnrc.yml` and `README.md` sit at the top too. What's different from a single app:

| File | What changes |
|---|---|
| `package.json` | The template's, at the top, with the same dependencies. Its scripts pass the app's folder to Vite: `vite dev apps/web`, `vite build apps/web`, and with `app-ssr`, `node apps/web/dist/server/server.js`. Vite's root is `apps/web`, so the build goes to `apps/web/dist/` |
| `tsconfig.base.json` | The single app's `tsconfig.json`, with one addition: `paths` maps `@shop/ui` to `./libs/ui/src/index.ts`. The scope is the package name, so a directory named `shop` gives `@shop`. Every project's `tsconfig.json` extends it |
| `apps/web/vite.config.ts`, `vitest.config.ts` | Add `resolve: { tsconfigPaths: true }`, so Vite resolves `@shop/ui` through those `paths`. That's Vite's own option, new in Vite 8, which the [Nx page](nx#tsconfig-paths-resolve-through-vite) uses too |
| `apps/web/src/app/home.ts` | Imports the library's component and shows it, so you can see the wiring work |
| `vitest.config.ts` at the top | Lists `apps/*` and `libs/*` as Vitest projects, so `npm test` runs every spec. Each folder has its own `vitest.config.ts` with `ngp()` and its own `test-setup.ts` |
| `libs/ui` | A component and its spec, exported from `src/index.ts`. Selectors in a library start with `lib`. It's exactly what `ngp-generate library ui` writes |

The library is never built by itself: the app compiles it with its own tsconfig, which is how a library that isn't buildable works in Nx, and what the plugin [does by design](https://github.com/push-based/vite-plugin-ngp/blob/main/docs/decisions.md#55-compile-apps-not-libraries). A template edit in `libs/ui` updates the page in place, like one in the app, and its template errors fail `vite build` with the app's.

To add a library, run [`ngp-generate library`](generating-code#libraries) from anywhere in the monorepo. It writes `libs/<name>` and adds its path to `tsconfig.base.json`, and the top `vitest.config.ts` picks up its specs. A second app is [`ngp-generate application admin`](generating-code#applications): `apps/admin`, laid out like `apps/web`, with `dev:admin`, `build:admin` and `preview:admin` scripts.

## After you scaffold

If you haven't used the plugin before, the [Tutorial](tutorial) takes the `app` template through a template edit, a type error, its spec and a build, with what you should see at each step.

### Upgrade the plugin

The plugin is pinned exactly, so it only moves when you move it:

```bash
npm install -D -E @push-based/vite-plugin-ngp@latest
```

With pnpm, `pnpm add -D -E` takes the same package. Before you do, look the new version up in [Compatibility](compatibility#angular-by-plugin-version). Each plugin release accepts one range of Angular, and if yours isn't in the new range, move Angular in the same step. The [changelog](changelog) says what changed.

### Move Angular

Change every `@angular/*` version in `package.json` to one release the plugin accepts, then install. Keep them all on the same release: `@angular/compiler` writes code for the `@angular/core` of its own release. `@angular/ssr` in `app-ssr` is the one exception. It takes the Angular CLI's newest release of the same minor, which can be behind the framework's: `22.3.0` next to `22.3.2` today.

### Add what the templates don't set

| You want | Do this |
|---|---|
| More than one language | The [`i18n`](i18n) option, in `vite.config.ts`. Not with `app-ssr` yet |
| zone.js | Install `zone.js`, set `ngp({ polyfills: ['zone.js'] })`, and add `provideZoneChangeDetection()` to `app.config.ts`. See [Polyfills and zone.js](migrating-from-ng-build#polyfills-and-zone-js) |
| Environment files | [`fileReplacements`](configuration#filereplacements), picked by Vite's `mode` |
| Other size limits | Edit `budgets`, or delete it. See [Budgets](migrating-from-ng-build#budgets) |
| Sass | `npm install -D sass`, then rename the stylesheet. See [Component styles](styles) |
| Specs on jsdom or in a browser | [Setup: jsdom](testing#setup-jsdom) or [Setup: browser mode](testing#setup-browser-mode) |
| Vite+ | `vp migrate` in the app's folder. See [Using Vite+](vite-plus#move-an-existing-app-to-vite) |

Every option is on [Configuration](configuration). Remember that an option meant for your specs goes in `vitest.config.ts` too.

### Add components

There's no `ng generate`, but the plugin brings `ngp-generate`, which writes the same files: `npx ngp-generate c user-card`. [Generating code](generating-code) lists what it writes.

## Where this is weak

- **Two templates.** Both are standalone and zoneless, and the server is Express. There's no zone.js or NgModule app, no publishable library (the plugin [compiles apps only](status)), no Nx workspace (see [Migrating inside Nx](nx)), and no other server, such as Cloudflare Workers.
- **The monorepo is one package.** Libraries aren't packages with their own `package.json`, so you can't publish one, version it, or give it dependencies of its own, and package-manager tools that work per package, such as `pnpm -r` or `vp run -r`, see one package. That was deliberate: workspace packages need `workspace:*` for pnpm, Yarn and bun and a plain version for npm, and the scaffolder can't tell which one `vp create` will install with. CI builds an `app-ssr` monorepo, prerenders it, runs its specs, adds a library and renders pages, and runs an `app` monorepo through `vp migrate`, `vp check`, `vp build` and `vp test`.
- **What's been run.** CI scaffolds both templates, installs them with pnpm, builds them, runs their spec and renders a page from the dev server and the build, as a Vite project and again after `vp migrate`. It also runs `app-ssr` through `yarn create` and builds it with Yarn 4.19.0, with Yarn's release-age gate off (below). npm 11.21.3 and bun 1.4.5 were run by hand once, on 2 December 2026, with the published 0.4.3: each scaffolded `app`, installed it, built it and passed its spec. Nothing runs them since. On Windows, CI scaffolds both templates and installs them, but `vite build` fails ([Status](status#what-doesnt-work-yet)).
- **Yarn refuses a version from the last day.** Yarn 4.19.0 doesn't install a version npm has had for less than 24 hours: its `npmMinimalAgeGate` is 1440 minutes unless you set it. On 2 December 2026, 15 hours after Angular published `22.3.2`, `yarn install` in a new `app-ssr` stopped with `@angular/common@npm:22.3.2: All versions satisfying "22.3.2" are quarantined`. The templates pin exact versions, the plugin's own among them, so expect the same for a day after each plugin release. That part is reasoning from the one failure, not something that was run. Wait a day, or install once with `YARN_NPM_MINIMAL_AGE_GATE=0 yarn install`, which is what CI's Yarn run does.
- **The Angular pin lags.** The templates pin the release the ngp build came from, which can be older than the newest release the plugin accepts. Move Angular yourself if you want the newest.
