Skip to main content
net10.0net8.0net9.0

.NET Aspire hosting extensions for Logto (includes PostgreSQL and Redis integration).

Published
Aug 25, 2026
1mo ago
Total Downloads
2.3K
2,278

Install

dotnet add package CommunityToolkit.Aspire.Hosting.Logto --version 13.5.0
ProductVersions
.NET
net10.0net8.0net9.0

README

Logto Hosting Extensions for .NET Aspire

Overview

This package provides .NET Aspire hosting extensions for integrating Logto with your AppHost. It includes helpers for wiring Logto to PostgreSQL (via Aspire.Hosting.Postgres.AddPostgres()) and optional Redis caching, and exposes fluent APIs to configure the required environment variables for Logto database connectivity, initialization, and caching.


Features

  • Configure Logto to use PostgreSQL via AddLogto(...).
  • Optional Redis integration for caching via .WithRedis(...).
  • Fluent helpers to set environment variables:
    • DB_URL (Postgres connection string)
    • REDIS_URL
    • NODE_ENV
    • ADMIN_ENDPOINT
  • Data persistence via:
    • .WithDataVolume() (managed Docker volume)
    • .WithDataBindMount() (host bind mount).
  • Configurable Admin Console access and proxy header trust (TRUST_PROXY_HEADER).
  • Built-in health check for /api/status.

Usage (AppHost)

using Aspire.Hosting;
using Aspire.Hosting.Postgres;
var postgres = builder.AddPostgres("postgres");

// Basic setup connecting to Postgres
var logto = builder
    .AddLogto("logto", postgres)
    .WithDatabaseSeeding();

// Advanced setup with Redis and specific configurations
var redis = builder.AddRedis("redis");

var logtoSecure = builder
    .AddLogto("logto-secure", postgres, databaseName: "logto_secure_db")
    .WithRedis(redis)
    .WithAdminEndpoint("https://admin.example.com")
    .WithDisableAdminConsole(false)
    .WithTrustProxyHeader(true)      // optional override, default is already true
    .WithSensitiveUsername(true)
    .WithNodeEnv("production");

Logto will be configured with:

  • DB_URL=postgresql://.../logto_db (constructed from the Postgres resource)
  • REDIS_URL=... (when Redis is attached with .WithRedis(...))
  • ADMIN_ENDPOINT=... (when configured with .WithAdminEndpoint(...))
  • NODE_ENV=production (when configured with .WithNodeEnv(...))
  • Auto-configured health checks on /api/status.

Notes

  • Extension methods are in the Aspire.Hosting namespace.
  • Call .WithDatabaseSeeding() to run the database seeding command npm run cli db seed -- --swe && npm start on startup.
  • Container ports are 3001 (HTTP) and 3002 (Admin). Host ports are random by default unless explicitly configured.

Changes from Previous Version

No structural changes between v13.5.0-beta.731 and v13.5.0.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

Compatibility metadata lists 3 target frameworks; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.