Sitemap
Mohit Kushwah

Mohit Kushwah

Passionate Frontend Developer | JavaScript | Angular

Angular Library: Create Library with Angular

1 min readMay 12, 2025

Today we are going to see how can we build a library in angular which we can share across the angular applications.

First we are going to create a library project with ng new

ng new app-library

Next, create a library for eg i will create for advance search

ng generate library as-lib — prefix=as

This command will do several changes to our app
1. It will create projects folder with as-lib as sub folder
and a module, a service and a component.
2. It will update angular.json
3. It will update tsconfig.json
4. There will be a public.api.ts file inside as-lib folder where everything should be exported so just check it.

Next we can add components or services or modules if required to library and do our development of library.

Get Mohit Kushwah’s stories in your inbox

Join Medium for free to get updates from this writer.

Next once we are done lets build it

ng build as-lib — prod

Now we will have as-lib folder in our dist, which we can use it in other application by publishing.

If you want to create a .tgz file from it just go to dist folder
go to library folder which is as-lib in this case and run

npm pack

This will create a .tgz file which you can publish to npm or any private registry.

Install commands
local — npm install <path-to-tgz>
published — npm install <package-name>

After installing npm package we can use it.

Thanks!

--

--

Mohit Kushwah
Mohit Kushwah

Written by Mohit Kushwah

Passionate Frontend Developer | JavaScript | Angular