serverpod-webserver

Implement Relic-based HTTP routing and static asset serving for Serverpod applications.

3.2k|369|Updated May 22, 2021
One-click install
npx skills add https://github.com/serverpod/serverpod --skill serverpod-webserver
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: serverpod-webserver
Source: https://github.com/serverpod/serverpod/tree/main/packages/serverpod/skills/serverpod-webserver
Command: npx skills add https://github.com/serverpod/serverpod --skill serverpod-webserver

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

You need a production-ready HTTP layer for your Serverpod project, including REST endpoints and web content delivery, without bolting together separate routing, middleware, and static/SPAs hosting.

Core Features & Use Cases

  • REST route handling with shared server Session: Build custom routes by extending Route and implementing handleCall(Session, Request) while reusing the same database, logging, and auth context.
  • Middleware, request context, and routing controls: Apply middleware to path prefixes, pass request-scoped values with ContextProperty, and use method restrictions and path/query parameter parsing.
  • Web delivery for HTML, SPAs, and Flutter web: Serve static assets, server-rendered Mustache templates, SpaRoute with index fallback, and FlutterRoute for Flutter web builds with sensible caching and optional WASM headers.

Quick Start

Use the serverpod-webserver skill to add a route by creating a Route subclass, then registering it on pod.webServer (the optional webServer listener) before pod.start().

Frequently Asked Questions about serverpod-webserver

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I serve a Flutter web app from a Serverpod backend?

Serve a Flutter web app from a Serverpod backend by registering a FlutterRoute on the webServer listener, which handles static assets and applies sensible caching with optional WASM headers.

How do I build REST APIs in Serverpod with shared database sessions?

Build REST APIs in Serverpod by extending the Route class and implementing handleCall(Session, Request), allowing your endpoints to reuse the same database, logging, and authentication context.

What is SPA fallback and how does it work for single page applications?

SPA fallback redirects unmatched client-side routes to an index file, ensuring single page applications load correctly. Serverpod uses SpaRoute with index fallback to manage this HTTP routing behavior.

Can I apply middleware to specific path prefixes in a Serverpod web server?

Yes, you can apply middleware to specific path prefixes in a Serverpod web server, passing request-scoped values using ContextProperty and enforcing method restrictions on incoming HTTP requests.

Does Serverpod support server-rendered HTML templates?

Yes, Serverpod supports server-rendered HTML templates using Mustache, enabling dynamic web content delivery alongside REST endpoints and static file hosting within the same Relic-based HTTP server.

Why is route registration order important when adding endpoints to a Serverpod web server?

Route registration order is critical because the webServer listener evaluates rules sequentially, meaning static file routes or SPA fallbacks must be registered after specific REST endpoints to prevent them from intercepting API traffic.