Skip to content

Add middleware support to RPC in Serverpod #4194

Description

@SandPod

Problem to Solve

Currently, Serverpod's RPC system does not support middleware functionality, which makes it challenging to implement cross-cutting concerns, logging, or custom request preprocessing for all or selected RPC endpoints.

Proposal

Introduce middleware capabilities to the RPC handling process in Serverpod. This would allow developers to add custom functions that can intercept, process, or modify requests and responses as they pass through the RPC pipeline. Middleware should support chaining and provide mechanisms for both synchronous and asynchronous operations.

Use Case

For example, a developer could add an authentication middleware to automatically check user credentials on every RPC request, or add logging middleware to track request/response payloads. This would centralize common logic and reduce code duplication across RPC handlers.

Alternatives

Currently, to add such functionality, developers must manually insert logic into each endpoint or handler, which reduces maintainability and increases risk of inconsistency. Some developers might use hooks or custom wrappers, but these approaches are less flexible compared to a dedicated middleware system.

Additional context

Adding middleware support to the RPC in Serverpod would make it more extensible and allow for better separation of concerns. This feature is common in many web frameworks, and its inclusion would improve developer experience.

How experienced are you with this library?

No response

Are you interested in working on a PR for this?

  • I want to work on this

Activity

  1. added theissue type on Nov 12, 2025
  2. added
    enhancement
    on Nov 12, 2025
  3. added
    area: endpoints
    on Nov 12, 2025
  4. moved this from Inbox 📫 to Contributor In Progress 👩‍💻 in Serverpod Frameworkson Nov 12, 2025
  5. linked a pull request that will close this issuefeat: Add support for RPC middlewares #4126on Nov 12, 2025
  6. gitrema commented on Nov 12, 2025

    @gitrema
    Contributor

    The proposal LGTM

  7. jwelmac commented on Nov 12, 2025

    @jwelmac
    Contributor

    This looks like an awesome addition.

  8. moved this from Contributor In Progress 👩‍💻 to Done 🚀 in Serverpod Frameworkson Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: endpointsenhancement

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions