โ— Shell
clean mode source โ†—

GitHub - limitless-angular/limitless-angular: Limitless Angular is a collection of powerful Angular libraries designed to enhance the Angular ecosystem and help developers build better applications with a focus on Sanity.io integration.

Twitter Follow npm version npm downloads

Limitless Angular is a powerful collection of Angular libraries focused on Sanity.io integration, designed to enhance your development experience with features like Portable Text rendering, image optimization, real-time previews, and visual editing.

Quick Links

Features

  • โœจ Portable Text: Complete implementation for rendering Sanity's Portable Text
  • ๐Ÿ–ผ๏ธ Image Optimization: Built-in image loader and directives for Sanity images
  • ๐Ÿ”„ Real-time Preview: Live content updates with Preview Kit
  • โœ๏ธ Visual Editing: Seamless content management integration
  • ๐ŸŽฏ Angular-First: Built specifically for Angular 20+

Installation

npm install --save @limitless-angular/sanity @sanity/client

Version Compatibility

Angular @limitless-angular/sanity
22.x 22.x
21.x 22.x, 21.x
20.x 22.x, 21.x, 20.x
19.x 21.x, 20.x, 19.x
18.x 20.x, 19.x, 18.x

The current stable 21.x package line supports Angular 19, Angular 20, and Angular 21.

Angular 22 support is available on the next prerelease line:

npm install @limitless-angular/sanity@next

Quick Start

Basic Configuration

For image optimization features:

import { ApplicationConfig } from '@angular/core';
import { provideSanity } from '@limitless-angular/sanity';

export const appConfig: ApplicationConfig = {
  providers: [
    provideSanity({
      projectId: 'your-project-id',
      dataset: 'your-dataset',
    }),
  ],
};

Preview Kit & Visual Editing Configuration

For preview and visual editing features, use the client factory approach:

import { provideSanity, withLivePreview } from '@limitless-angular/sanity';
import { createClient } from '@sanity/client';

const client = createClient({
  projectId: 'your-project-id',
  dataset: 'your-dataset',
  apiVersion: 'YYYY-MM-DD',
  useCdn: true,
});

const getClientFactory = (preview?: { token: string }) =>
  preview?.token
    ? client.withConfig({
        token: preview.token,
        useCdn: false,
        ignoreBrowserTokenWarning: true,
        perspective: 'drafts',
        stega: {
          enabled: true,
          studioUrl: 'your-studio-url',
        },
      })
    : client;

export const appConfig: ApplicationConfig = {
  providers: [provideSanity(getClientFactory, withLivePreview())],
};

Features

Portable Text

Render Portable Text with Angular.

@Component({
  imports: [PortableTextComponent],
  template: `<div portable-text [value]="content" [components]="components"></div>`,
})
export class ContentComponent {
  content = [
    /* your portable text content */
  ];
  components: PortableTextComponents = {
    // Custom components configuration
  };
}

๐Ÿ“š Portable Text Documentation

Image Handling

Powerful features for working with Sanity images in Angular applications:

@Component({
  imports: [SanityImage],
  template: `
    <img
      [sanityImage]="imageRef"
      width="800"
      height="600"
      [alt]="imageRef.alt"
    />
  `,
})

๐Ÿ“š Image Loader Documentation

Preview Kit

The Preview Kit provides real-time preview capabilities for Sanity content in Angular applications, enabling live updates of content as it's being edited in the Sanity Studio:

import { LiveQueryProviderComponent } from '@limitless-angular/sanity/preview-kit';

@Component({
  imports: [LiveQueryProviderComponent],
  template: `
    @if (draftMode()) {
      <live-query-provider [token]="token">
        <router-outlet />
      </live-query-provider>
    } @else {
      <router-outlet />
    }
  `,
})
export class AppComponent {
  draftMode = signal(false);
  token = signal('your-preview-token');
}

๐Ÿ“š Preview Kit Documentation

Visual Editing

The Visual Editing feature allows editors to click elements in your preview to navigate directly to the corresponding document and field in Sanity Studio.

@Component({
  imports: [VisualEditingComponent],
  template: `
    <main>
      <router-outlet />
      @if (draftMode()) {
        <visual-editing />
      }
    </main>
  `,
})
export class AppComponent {}

๐Ÿ“š Visual Editing Documentation

Analog Blog Studio

The Analog blog example can be edited inside a first-class Sanity Studio through Presentation. The shared blog contract lives in the source-only @limitless-angular/analog-sanity-blog workspace package, so the Analog app and Studio import the same schemas, GROQ queries, Presentation routes, and Studio structure without adding another build artifact.

pnpm blog:setup
pnpm blog:dev

Open http://localhost:3333/presentation after both dev servers start.

After changing blog schemas or GROQ queries, regenerate the frontend query types:

Roadmap

  • ๐ŸŽฏ Performance optimizations
  • ๐Ÿ“š Enhanced documentation and examples
  • โœ… Comprehensive test coverage
  • ๐Ÿ”„ Lazy loading for Portable Text components

Contributing

We welcome contributions! Check our Contributing Guide for details.

Support

Credits

Adapted from @portabletext/react v6.2.0 which provided the vast majority of node rendering logic.

License

This project is licensed under the MIT License. See our LICENSE file for details.