PocketBase.Blazor 0.0.3

dotnet add package PocketBase.Blazor --version 0.0.3
                    
NuGet\Install-Package PocketBase.Blazor -Version 0.0.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PocketBase.Blazor" Version="0.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PocketBase.Blazor" Version="0.0.3" />
                    
Directory.Packages.props
<PackageReference Include="PocketBase.Blazor" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PocketBase.Blazor --version 0.0.3
                    
#r "nuget: PocketBase.Blazor, 0.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package PocketBase.Blazor@0.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PocketBase.Blazor&version=0.0.3
                    
Install as a Cake Addin
#tool nuget:?package=PocketBase.Blazor&version=0.0.3
                    
Install as a Cake Tool

PocketBase.Blazor NuGet Version

PocketBase.Blazor is a lightweight, Blazor-friendly client wrapper for the PocketBase REST API. It simplifies working with PocketBase in both Blazor WebAssembly and Blazor Server projects by providing a minimal, strongly-typed API with built-in DI support.

Features

  • Minimalistic IPocketBaseClient + PocketBaseClient implementation using HttpClient.
  • Dependency Injection (DI) extension: AddPocketBase(options => { ... }).
  • PocketBaseOptions with pre-configured JsonSerializerOptions tailored for Blazor.
  • Strongly-typed API with automatic error handling for API responses.
  • Sample Blazor WebAssembly application to get you started quickly.
  • Unit test project skeleton using XUnit and Moq for HTTP client mocking.
  • GitHub Actions workflow for automated NuGet package publishing.
  • Local build and pack scripts for easy packaging and distribution.

Quickstart

Install from NuGet:

dotnet add package PocketBase.Blazor

Register services in Program.cs:

builder.Services.AddPocketBase(options =>
{
    options.BaseUrl = "https://your-pocketbase.example";
    options.ApiKey = "pb_pk_xxx"; // optional

    // Optional: tune JSON options (defaults are camelCase and ignore nulls)
    options.JsonSerializerOptions.PropertyNamingPolicy = System.Text.Json.JsonNamingPolicy.CamelCase;
    options.JsonSerializerOptions.DictionaryKeyPolicy = System.Text.Json.JsonNamingPolicy.CamelCase;
    options.JsonSerializerOptions.DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull;
    options.JsonSerializerOptions.PropertyNameCaseInsensitive = true;
});

Inject and use the client in your components:

@inject IPocketBaseClient Client

@code {
    private List<Post>? posts;

    protected override async Task OnInitializedAsync()
    {
        var (items, error) = await Client.GetListAsync<Post>("posts");
        if (error != null)
        {
            // Handle error (e.g., log or show a message)
        }
        else
        {
            posts = items;
        }
    }

    public class Post
    {
        public string Id { get; set; } = "";
        public string? Title { get; set; }
        public string? Slug { get; set; }
    }
}

Running Unit Tests

PocketBase.Blazor includes a test project using XUnit and Moq. To run the tests:

dotnet test ./tests/PocketBase.Blazor.Tests/PocketBase.Blazor.Tests.csproj

Deployment

Build & pack locally

./build-local.ps1

# macOs/Linux

dotnet clean ./src/PocketBase.Blazor/PocketBase.Blazor.csproj
dotnet build ./src/PocketBase.Blazor/PocketBase.Blazor.csproj -c Release
dotnet pack ./src/PocketBase.Blazor/PocketBase.Blazor.csproj -c Release -o ./nupkg

CI / Release

A GitHub Actions workflow is included to pack and publish to NuGet when a tag v* is pushed and NUGET_API_KEY is present in repository secrets.

Roadmap

  • Auth helpers (login/logout, token refresh)
  • Realtime support (if PocketBase offers a WASM-friendly realtime API)
  • Aspire integration hooks
  • More complete, generated models

Contributing

Contributions and issues are welcome. Please follow standard GitHub PR workflow.

License

This work is licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0).

You are free to:

  • Share — copy and redistribute the material in any medium or format
  • Adapt — remix, transform, and build upon the material for any purpose, including commercial

Under the following terms:

  • Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.

To view a copy of this license: https://creativecommons.org/licenses/by/4.0/

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.3 345 11/30/2025
0.0.2 338 11/30/2025
0.0.1 340 11/30/2025