npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

astrosharp

v0.0.3

Published

Write the coded parts of Astro (components, loaders, actions, endpoints, middleware) in C#.

Readme

astrosharp

Write the coded parts of an Astro site in C# instead of TypeScript. Components, content loaders, actions, endpoints and middleware can all be authored in C#, while Node and Vite continue to drive the build. This is a build-time and ergonomics project, not a runtime replacement: the .NET SDK runs alongside Node and executes the C# you write.

Requirements

  • Node 20 or newer.
  • The .NET SDK 10.0 or newer, on your PATH as dotnet. That is the only extra requirement — the compiled .NET host ships inside this package, so there is nothing else to install and no separate .NET project to maintain. The integration checks for a suitable SDK at startup and fails with an actionable message if dotnet is missing, too old, or runtime-only.

Install

npm install astrosharp
// astro.config.mjs
import { defineConfig } from 'astro/config';
import astrosharp from 'astrosharp';

export default defineConfig({ integrations: [astrosharp()] });

Write C# under src/, next to your .astro files, and run astro build. The integration generates and manages a throwaway .csproj under .astrosharp/.

What you can write

A component is an ordinary Razor component. A .razor file under src/pages becomes a route by its filename, exactly like .astro:

<h2>@Title</h2>

@code {
    [Parameter] public string Title { get; set; } = "";
}

A content loader implements IContentLoader, and is wired up from src/content.config.ts:

import { sharpLoader } from 'astrosharp/content';

export const collections = {
  blog: defineCollection({ loader: sharpLoader('blog'), schema: /* ... */ }),
};

An action implements IAstroAction<TInput, TOutput>. An endpoint implements IAstroEndpoint and serves the route its file names — src/pages/api/status.json.cs serves /api/status.json — taking HttpRequestMessage and returning HttpResponseMessage. Middleware implements IAstroMiddleware. The ambient Astro global is available in C# pages and components — Astro.Url, Astro.Params, Astro.Props, Astro.Locals, Astro.Request, Astro.Cookies and more — mirroring the .astro API.

Astro.Session, Astro.Cache and Astro.Csp are there too, for on-demand rendered routes:

@{
    var visits = Astro.Session.Get<int>("visits");
    Astro.Session.Set("visits", visits + 1);

    Astro.Cache.Set(maxAgeSeconds: 60, tags: new[] { "profile" });
    Astro.Csp.InsertDirective("img-src 'self'");
}

A @{ ... } block at the top of a component is the nearest equivalent to Astro's --- frontmatter: plain statements that run as the component renders. It is not the same as @code { }, which declares class members — fields, properties and methods — and cannot hold loose statements.

Reads are synchronous where Astro's equivalents are async: the state is resolved before the render and recorded mutations are replayed after it, because a Razor component cannot await mid-markup. So a value written with Set is not visible to a later Get in the same render. On a prerendered route all three report themselves unavailable and writes are discarded rather than throwing.

Astro.Logger writes into Astro's own build output, at the right level, and unlike the three above it works everywhere — prerendered routes and dev included:

Astro.Logger.Info("built 12 products");
Astro.Logger.Warn("no price for SKU-4");
Astro.Logger.Error("feed unavailable, using cache");

Messages appear once the component has finished rendering rather than at the moment of the call, and are still emitted if the render throws.

NuGet packages are declared in your package.json, since npm rejects a nuget: protocol in dependencies:

{
  "nugetDependencies": { "Humanizer": "2.14.1" }
}

Options

| Option | Default | Purpose | | --- | --- | --- | | srcDir | "src" | Directory holding your .razor and .cs files | | targetFramework | "net10.0" | Target framework for the generated project | | packages | {} | Extra NuGet packages, merged with nugetDependencies | | dotnet | "dotnet" | Path to the .NET CLI | | host / library | bundled | Override the bundled .NET assemblies (advanced) | | experimental.serverRendering | "off" | "sidecar" or "wasm" for on-demand rendering |

Documentation

In the repository, github.com/davidwhitney/AstroSharp:

  • docs/README.md — the index. Mirrors Astro's own documentation, page for page, showing the TypeScript and the C# equivalent for each topic.
  • docs/how-it-works.md — how the machinery fits together.

License

MIT © David Whitney