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

@lastshotlabs/slingshot-ssr

v0.0.2

Published

SSR, ISR, and page-routing plugin for Slingshot

Readme


title: Human Guide description: Human-maintained guidance for @lastshotlabs/slingshot-ssr

@lastshotlabs/slingshot-ssr is Slingshot's server-rendering package. It owns route resolution, server action routing, metadata routes, draft-mode routing, page-declaration support, and the middleware that turns Slingshot context plus a renderer into HTML responses.

When To Use It

Use this package when your app needs:

  • file-based server routes rendered on the server
  • route loaders that read directly from Slingshot context instead of making HTTP calls back into the app
  • metadata routes such as sitemap or robots behavior
  • server actions mounted under the Snapshot-compatible action endpoint
  • entity-driven page declarations, renderer navigation config, or ISR
  • hybrid deployments that mix SSR with pre-rendered static output

Minimum Setup

createSsrPlugin() has three practical requirements:

  • a renderer that satisfies the SlingshotSsrRenderer contract
  • serverRoutesDir
  • assetsManifest

After that, the most common optional config is:

  • cacheControl
  • exclude
  • devMode
  • staticDir
  • isr
  • trustedOrigins
  • serverActionsDir
  • runtime
  • draftModeSecret
  • pages
  • navigation

If you use layouts, your renderer also needs renderChain(). That requirement is architectural, not optional polish.

What You Get

The plugin wires several surfaces at once:

  • draft-mode routes under /api/draft when draftModeSecret is configured
  • server action routing under /_snapshot
  • metadata route registration from the server route tree
  • SSR middleware that resolves routes, loads data, and renders HTML
  • optional ISR invalidators stored in plugin state under slingshot-ssr:isr
  • optional page-declaration support for renderer-owned shell/navigation experiences
  • entity-event subscriptions that revalidate ISR tags for referenced pages

This is the package that makes route loaders, shell rendering, metadata, and revalidation behave as one system instead of separate app glue.

Common Customization

Start in these files:

  • src/plugin.ts for lifecycle and middleware registration
  • src/config.schema.ts for supported config and validation
  • src/types.ts for the renderer and loader contracts
  • src/resolver.ts and src/pageResolver.ts for route and page resolution
  • src/pageLoaders.ts for loader execution
  • src/metadata/ and src/draft/ for metadata and draft-mode behavior

The generated package reference for slingshot-ssr is sourced from entrypoint and type-level JSDoc, primarily src/index.ts plus the exported contracts in src/types.ts. If you change renderer, loader, page, metadata, draft-mode, or static-params behavior, update those comments in the same diff rather than trying to patch generated docs afterward.

The highest-leverage decisions are usually:

  • renderer contract shape
  • route resolution and exclusion behavior
  • ISR cache adapter choice
  • server action trust policy
  • whether pages are file-based, manifest-backed, or both

Gotchas

  • In production mode, startup fails if assetsManifest cannot be read or parsed. That is expected and should remain fail-closed.
  • serverRoutesDir and serverActionsDir must be absolute paths. Relative paths are rejected at config validation time so route resolution is reproducible across runtime hosts (Bun / Node / Lambda / Edge). Resolve via path.resolve(import.meta.dir, ...) or path.join(process.cwd(), ...) before passing them in.
  • renderChain() is required for layouts. If the renderer only implements render(), nested layout routing will not behave correctly.
  • When pages and ISR are both enabled, the plugin subscribes to CRUD events for referenced entities so tag revalidation works. Changing that path affects runtime invalidation semantics.
  • staticDir is a serving optimization for already-generated HTML, not a replacement for the SSR route tree.
  • The dev watcher is best-effort only. It invalidates and rebuilds the route tree when Bun's watch API is available.

Key Files

  • src/index.ts
  • src/plugin.ts
  • src/config.schema.ts
  • src/types.ts
  • src/resolver.ts
  • src/pageResolver.ts
  • src/pageLoaders.ts
  • src/metadata/index.ts

Source-Backed Examples