SolidJSS
SolidJS13mo ago
2 replies
snnsnn

Registering API Endpoints on SolidStart

Hi everyone! I’m exploring ways to programmatically register API endpoints in SolidStart without relying on FileRoutes. My goal is to fully control the paths manually instead of using the file-based routing system.

I know it’s possible to do this using a middleware like so:

import { createMiddleware } from "@solidjs/start/middleware";

export default createMiddleware({
  onRequest: [
    event => {
      // Custom logic here
    }
  ]
});

While this works, I’m wondering if there’s a simpler or more straightforward alternative.

Additionally, does the Solid Router support adding API endpoints directly, or is there a recommended way to handle API routing with it?

Using a middleware as shown above, is there a built-in utility in SolidStart to match routes and extract query parameters from the request? If so, how can it be used within the middleware?

I’d appreciate any guidance, examples, or tips. Thanks in advance!
Was this page helpful?