---
title: "@vonvon-kit/angular"
description: "Angular 17+ standalone provider, RxJS service, functional route guards, and standalone components on top of @vonvon-kit/core."
locale: "en"
---

> Documentation Index
> Fetch the relevant documentation index at: https://vonvon.id/sdks/llms.txt
> Use this file to discover all available pages before exploring further.

# @vonvon-kit/angular

## Status

Registry status: UNPUBLISHED. Install this SDK only from the repository source checkout; do not use an external package registry.

Package status is **Current package**. Angular 17+ standalone provider, RxJS service, functional guards, and standalone components are implemented. A real IdP round-trip on production infrastructure is still pending manual verification.

## Provider setup

Call `provideVonvon` in `app.config.ts`. It registers the `VONVON_CLIENT` injection token and wires an `APP_INITIALIZER` that calls `client.load()` on bootstrap. No NgModule required.

```ts
// app.config.ts
import { ApplicationConfig } from '@angular/core'
import { provideVonvon } from '@vonvon-kit/angular'

export const appConfig: ApplicationConfig = {
  providers: [
// Core auth endpoints must be served on this application's exact origin.
provideVonvon({ mode: 'same-origin' }),
  ],
}
```

## VonvonAuthService

```ts
import { Component, inject } from '@angular/core'
import { AsyncPipe } from '@angular/common'
import { VonvonAuthService } from '@vonvon-kit/angular'

@Component({
  selector: 'app-header',
  standalone: true,
  imports: [AsyncPipe],
  template: `
@if (auth.isLoaded$ | async) {
  @if (auth.isSignedIn$ | async) {
    <span>{{ (auth.user$ | async)?.primaryEmailAddress }}</span>
  } @else {
    <a routerLink="/sign-in">Sign in</a>
  }
}
  `,
})
export class HeaderComponent {
  readonly auth = inject(VonvonAuthService)
}
```

## Angular signals bridge

Use `toSignal()` from `@angular/core/rxjs-interop` to convert observables to signals for template reads.

```ts
import { toSignal } from '@angular/core/rxjs-interop'
import { inject } from '@angular/core'
import { VonvonAuthService } from '@vonvon-kit/angular'

@Component({ standalone: true, ... })
export class MyComponent {
  readonly #auth = inject(VonvonAuthService)
  readonly user = toSignal(this.#auth.user$, { initialValue: null })
}
```

## Route guards

```ts
import { Routes } from '@angular/router'
import { authGuard, hasOrganizationGuard, hasPermissionGuard } from '@vonvon-kit/angular'

export const routes: Routes = [
  {
path: 'dashboard',
canActivate: [authGuard()],
loadComponent: () => import('./dashboard.component').then(m => m.DashboardComponent),
  },
  {
path: 'admin',
canActivate: [hasPermissionGuard('org:settings:write')],
loadComponent: () => import('./admin.component').then(m => m.AdminComponent),
  },
]
```

## Standalone components

```html
<!-- template -->
<vonvon-sign-in-button signInUrl="/sign-in" redirectUrl="/dashboard">Log in</vonvon-sign-in-button>
<vonvon-sign-out-button redirectUrl="/home">Log out</vonvon-sign-out-button>
```

## Exported API

| Export | Kind | Purpose |
| --- | --- | --- |
| `provideVonvon` | function | Registers VONVON\_CLIENT singleton and APP\_INITIALIZER; accepts ProvideVonvonOptions |
| `VONVON_CLIENT` | InjectionToken | The raw VonvonClient instance; prefer VonvonAuthService for most use cases |
| `VonvonAuthService` | service | RxJS observables: state$, isLoaded$, isSignedIn$, user$, session$, organization$; plus getToken, signOut, setActiveOrganization, setActiveSession |
| `authGuard` | CanActivateFn factory | Redirects to /sign-in when user is not signed in |
| `hasOrganizationGuard` | CanActivateFn factory | Redirects when no active organization context is present |
| `hasPermissionGuard` | CanActivateFn factory | Redirects when user lacks the specified permission |
| `SignInButton` | standalone component | Selector vonvon-sign-in-button; inputs signInUrl, redirectUrl, ariaLabel |
| `SignOutButton` | standalone component | Selector vonvon-sign-out-button; inputs sessionId, redirectUrl, ariaLabel; shows aria-busy while signing out |

Source: https://vonvon.id/sdks/angular/index.mdx
