On this page
Tutorial
This page is for an Angular developer who has never run vite-plugin-ngp and wants to see what it does before moving a real app. You'll create a small app, edit it while it runs, break it on purpose, and build it. Each step shows what you should see, so you can tell when something is off.
Every step was run as written on 4 December 2026, with create-ngp 0.4.4, Angular 22.3.2 and Vite 8.3.4, on an Apple M4 Max. The times in the terminal excerpts are from that run; yours will differ.
You need Node 26 or later, and macOS or Linux. To move an app you already have instead, see Getting started.
1. Create the app and start it#
npm create @push-based/ngp@latest -- shop --template app --no-monorepoThe options answer the scaffolder's questions, so it asks nothing: an app called shop, rendered in the browser, on its own rather than in a monorepo. Creating an app has the other choices. It writes the app and prints what to run next:
Scaffolded app into …/shop.
Done. Now run:
cd shop
npm install
npm run devRun those three. npm install warns that @angular/platform-browser-dynamic is deprecated: the spec needs it, and the warning is Angular's. Newer npm releases also list esbuild's install script as not yet allowed; the plugin doesn't need it. Then the dev server starts:
VITE v8.3.4 ready in 807 ms
➜ Local: http://localhost:5173/Open http://localhost:5173/. You should see a heading, "Angular on Vite", a button that says Clicks: 0, a Home link, and a line of text from the one route, src/app/home.ts.
The plugin compiled each of those modules when the browser asked for it, and only that one, with ngp: Angular's compiler split so it can answer one file at a time. ng serve compiles the whole program first. How it works explains the difference.
2. Edit a template, then the class#
Click the button three times, so it says Clicks: 3. That count lives in a signal in src/app/app.ts:
export class App {
protected readonly clicks = signal(0);
protected count(): void {
this.clicks.update((n) => n + 1);
}
}Now open src/app/app.html, the component's template, change the heading and save:
<h1>My shop</h1>The heading changes and the button still says Clicks: 3. The page didn't reload; Angular swapped the new template into the running component and kept its state. The terminal names the component it updated:
5:28:08 AM [vite] hmr update src/app/app.ts@AppNow change the class instead. In src/app/app.ts, make each click count twice:
this.clicks.update((n) => n + 2);This time the page reloads. The button is back at Clicks: 0, and one click takes it to 2. The terminal says so:
5:28:15 AM [vite] (client) page reload src/app/app.tsThe rule is the Angular CLI's: a change to a component's template updates in place, and any other change to its .ts file reloads the page. An external template like app.html updates in place, and so does a .ts edit that only touches the inline template or styles in a component's decorator. Try it in src/app/home.ts, whose template is inline: change its text and the page updates with the count kept. A method, an input, an import or a new entry in imports reloads, because the running page doesn't have that code yet. How it works has the details, including the two cases where the plugin reloads and ng serve doesn't.
3. Break a template on purpose#
In src/app/app.html, misspell the signal the button shows, and save:
<button type="button" (click)="count()">Clicks: {{ clikcs() }}</button>Two things happen, in this order.
First, the edit reaches the page like any other template edit. The plugin never makes an edit wait for the type-check, so Angular runs the broken template, finds no clikcs on the component, and throws. The plugin sees the update fail and reloads the page. You'll see ctx.clikcs is not a function in the browser console and in the terminal.
Then, a moment later, the type-check reports the real cause in the terminal, at the template's line and column:
5:28:31 AM [vite] [vite-plugin-ngp] type-check: 1 error (121 ms)
src/app/app.html:9:54 - error TS2551: Property 'clikcs' does not exist on type 'App'. Did you mean 'clicks'?
7 |
8 | <main>
> 9 | <button type="button" (click)="count()">Clicks: {{ clikcs() }}</button>
| ^
10 |
11 | <nav>The browser shows the same error in Vite's overlay, over the page, with a link that opens the template at line 9, column 54. The check runs tsgo, TypeScript 7, with your strictTemplates setting, over every file your tsconfig includes, so an error in a route you haven't opened shows up too. Type-checking says when it runs and what it checks.
Fix the typo and save. The overlay closes, the button is back, and the terminal says:
5:28:43 AM [vite] [vite-plugin-ngp] type-check: no errors (163 ms)Stop the dev server with Ctrl+C.
4. Run the spec and build#
The app comes with one spec, src/app/app.spec.ts, which clicks the button once under Vitest. Run it:
npm testIt fails, and it should: you made a click count twice in step 2, and the spec still expects one.
FAIL src/app/app.spec.ts > App > counts clicks
AssertionError: expected 'Clicks: 2' to contain 'Clicks: 1'Change 'Clicks: 1' to 'Clicks: 2' in the spec and run it again:
Test Files 1 passed (1)
Tests 1 passed (1)The spec ran on Angular's server platform, in Node, compiled by the same plugin as the dev server. Testing with Vitest explains the setup and the other two ways to run it.
Now build:
npm run build✓ 264 modules transformed.
rendering chunks...
[vite-plugin-ngp] type-check: no errors (114 ms)
computing gzip size...
dist/index.html 0.45 kB │ gzip: 0.28 kB
dist/assets/index-10LEKZJ3.css 0.23 kB │ gzip: 0.15 kB
dist/assets/home-BSg9VzcZ.js 0.40 kB │ gzip: 0.30 kB
dist/assets/index-B1VsoMKm.js 211.66 kB │ gzip: 64.31 kB
✓ built in 1.23sThe build runs the same type-check as the dev server, and fails on any error. To see it, put the clikcs typo back and build again:
✗ Build failed in 702ms
error during build:
Build failed with 1 error:
[plugin vite-plugin-ngp]
RolldownError: [vite-plugin-ngp] type-check: 1 error (153 ms)
src/app/app.html:9:54 - error TS2551: Property 'clikcs' does not exist on type 'App'. Did you mean 'clicks'?The failed build empties dist/ first, so fix the typo and build once more before you serve it. npm run preview serves dist/, at http://localhost:4173/ unless you pass --port, the way a static host would. home-*.js is the lazy route, in a chunk of its own.
You can delete the shop folder when you're done.
Where next#
- Getting started moves an app you already have onto the plugin.
- Configuration lists every option, and what the plugin sets up in Vite for you.
- How it works explains what you just saw: compiling per module, handling an edit, and component HMR.