Class ServiceCollectionExtensions
- Namespace
- Ramstack.HtmxToolkit.Hosting
- Assembly
- Ramstack.HtmxToolkit.dll
Provides HTMX Toolkit service registration for an IServiceCollection.
public static class ServiceCollectionExtensions
- Inheritance
-
ServiceCollectionExtensions
- Inherited Members
Methods
AddHtmxToolkit(IServiceCollection, Action<HtmxToolkitOptions>?)
Registers and configures HTMX Toolkit services.
public static IServiceCollection AddHtmxToolkit(this IServiceCollection services, Action<HtmxToolkitOptions>? configure = null)
Parameters
servicesIServiceCollectionThe service collection.
configureAction<HtmxToolkitOptions>An optional delegate used to configure HTMX Toolkit.
Returns
- IServiceCollection
The same
servicescollection.
Examples
using Ramstack.HtmxToolkit.Hosting;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorPages();
// HTMX 2.x is the default. Select the version that your pages load,
// and set only the HTMX options that should differ from the HTMX defaults.
builder.Services.AddHtmxToolkit(options =>
{
options.UseHtmxV4(config =>
{
config.DefaultTimeout = 10_000;
});
});