Add authentication to your Angular application
This guide will show you how to integrate Logto Angular SDK v2 into your application.
tip:
- This guide uses the first-party
@logto/angularv2 SDK, which supports Angular 20 and provides dependency injection and Signals. - The sample project is available in our SDK repository.
Prerequisites
- A Logto Cloud account or a self-hosted Logto.
- A single-page application (SPA) created in Logto Console.
- An Angular 20 project.
Installation
Install Logto SDK via your favorite package manager:
- npm
- pnpm
- yarn
npm i @logto/angularpnpm add @logto/angularyarn add @logto/angularIntegration
Init Logto provider
In your Angular project, register provideLogto and your application routes in app.config.ts:
app/app.config.ts
import { type ApplicationConfig } from '@angular/core';
import { provideRouter } from '@angular/router';
import { provideLogto } from '@logto/angular';
import { routes } from './app.routes';
export const appConfig: ApplicationConfig = {
providers: [
provideLogto({
endpoint: '<your-logto-endpoint>',