Loading

Frontend package

The Pagefind.Net.Frontend NuGet package ships the Pagefind browser query runtime: pagefind.js and wasm.en.pagefind. These files are required for the search UI to work in the browser.

When you install the package, an MSBuild target runs after every build and copies the runtime files into your project:

wwwroot/pagefind/
  pagefind.js
  wasm.en.pagefind
		
Tip

No configuration is needed for the default setup. The index data files written by PagefindIndex.WriteAsync go into the same directory.

Set PagefindFrontendOutputPath in your .csproj:

<PropertyGroup>
  <PagefindFrontendOutputPath>wwwroot/_search</PagefindFrontendOutputPath>
</PropertyGroup>
		

If you prefer to manage runtime files yourself:

<PropertyGroup>
  <PagefindFrontendDisableExtract>true</PagefindFrontendDisableExtract>
</PropertyGroup>
		

The PagefindFrontend static class provides an ExtractToAsync method for extracting files from code:

using Pagefind.Net.Frontend;

// Extract to a directory (skips if already up to date)
string[] written = await PagefindFrontend.ExtractToAsync("wwwroot/pagefind");

// Force overwrite
string[] written = await PagefindFrontend.ExtractToAsync("wwwroot/pagefind", force: true);
		
Note

A version marker file (.pagefind-net-frontend-version) is written alongside the assets. On subsequent calls, extraction is skipped if the marker matches the current package version and all expected files exist.

An overload accepting IFileSystem (from System.IO.Abstractions) is available for unit testing.

This package ships the runtime from Pagefind 1.5.2. The version is available programmatically:

Console.WriteLine(PagefindFrontend.Version); // "1.5.2"