0Pricing
Angular Academy · Lesson

Creating a Library with ng generate

Scaffold a library project.

Why Build a Library

When several apps need the same components, services, or utilities, you package them as an Angular library. A library is reusable, versioned, and publishable, instead of copy-pasting code between projects.

Workspaces Hold Libraries

Libraries live inside an Angular workspace: a folder managed by one angular.json that can contain multiple apps and libraries. You can add a library to an existing workspace or create a dedicated one.

ng new my-workspace --create-application=false
# a workspace with no app, ready to hold libraries

All lessons in this course

  1. Creating a Library with ng generate
  2. Public API and Entry Points
  3. Building with ng-packagr
  4. Publishing to npm
← Back to Angular Academy