--- title: Installing Unhead with Angular description: Learn how to start using Unhead with Angular. navigation: title: 'Installation' --- Unhead provides first-class support for Angular, allowing you to manage your head tags using composables like `useHead()`, `useSeoMeta()`, and others within your Angular components. - [StackBlitz - Unhead - Angular](https://stackblitz.com/edit/stackblitz-starters-e4x42yaz) ## Setup ### 1. Add Dependency Install the Angular-specific Unhead package: :ModuleInstall{name="@unhead/angular"} ### 2. Setup Client-Side Rendering To enable Unhead in your Angular application, you need to set up the client provider. This is typically done by creating or modifying your application configuration: ```ts {3,7} [src/app/app.config.client.ts] import { ApplicationConfig, mergeApplicationConfig } from '@angular/core' import { provideClientHead } from '@unhead/angular/client' import { appConfig } from './app.config' const clientConfig: ApplicationConfig = { providers: [ provideClientHead(), ] } export const config = mergeApplicationConfig(appConfig, clientConfig) ``` Then use this configuration in your main client-side bootstrap file: ```ts [src/main.ts] import { bootstrapApplication } from '@angular/platform-browser' import { AppComponent } from './app/app.component' import { config } from './app/app.config.client' bootstrapApplication(AppComponent, config) .catch(err => console.error(err)) ``` ### 3. Setup Server-Side Rendering (Optional) ::note Not using Server-Side Rendering? You can skip this step. :: If you're using Angular Universal or another SSR setup, you'll need to configure Unhead for the server: ```ts [src/app/app.config.server.ts] import { ApplicationConfig, mergeApplicationConfig } from '@angular/core' import { provideServerRendering } from '@angular/platform-server' import { provideServerRoutesConfig } from '@angular/ssr' import { provideServerHead } from '@unhead/angular/server' import { appConfig } from './app.config' import { serverRoutes } from './app.routes.server' const serverConfig: ApplicationConfig = { providers: [ provideServerRendering(), provideServerRoutesConfig(serverRoutes), provideServerHead({ // Optional initial default values init: [ { htmlAttrs: { lang: 'en', }, title: 'Default Title', meta: [ { name: 'description', content: 'Default description' } ] } ] }), ] } export const config = mergeApplicationConfig(appConfig, serverConfig) ``` Then use this configuration in your server bootstrap file: ```ts [src/main.server.ts] import { bootstrapApplication } from '@angular/platform-browser' import { AppComponent } from './app/app.component' import { config } from './app/app.config.server' const bootstrap = () => bootstrapApplication(AppComponent, config) export default bootstrap ``` ### 4. Using Unhead in Components Once set up, you can use Unhead's composables in your Angular components: ```ts [src/app/app.component.ts] import { Component } from '@angular/core' import { useHead, useSeoMeta } from '@unhead/angular' @Component({ selector: 'app-root', template: `