Silgi

Remix

Use Silgi with Remix action/loader routes.

Remix uses file-based routing with action and loader exports. Silgi integrates via a catch-all splat route.

Setup

Create a catch-all route:

// app/routes/api.$.tsx
import {  } from 'silgi/remix'
import {  } from '~/server/rpc'

const  = (, {
  : () => ({
    : getDB(),
    : .(.request.headers),
  }),
})

export const  = 
export const  = 

Procedures are accessible at:

POST /api/users/list
POST /api/users/create
GET  /api/health

Context from Remix loaders

The context function receives the standard Remix LoaderFunctionArgs / ActionFunctionArgs object:

createHandler(appRouter, {
  : () => ({
    : .context.user, // from Remix server context
    : .params,
  }),
})

Analytics and Scalar

Enable the built-in analytics dashboard or Scalar API reference directly in the adapter:

const  = createHandler(appRouter, {
  : () => ({ : .(.request.headers) }),
  : {
    : process.env.ANALYTICS_TOKEN,
  },
  : true,
})

What's next?

  • Analytics — built-in monitoring dashboard
  • Server — standalone serve() as an alternative
  • Integrations — other available integrations

On this page