The Docs.

Prim+RPC is in prerelease mode and may be unstable until official release.
All Plugins

Hono

Plugin Details
  • Plugin Type:
    Method Handler
  • Transport:
    HTTP
  • Works with:

Prim+RPC supports Hono and is very easy to set up. First, let’s set up our functions to be used on the server:

export function hello() {
	return "Hi from Prim+RPC!"
}
hello.rpc = "idempotent"
 
export default hello

We can expose these functions to the client by setting up Hono and Prim+RPC:

import { createPrimServer } from "@doseofted/prim-rpc"
import { createMethodHandler } from "@doseofted/prim-rpc-plugins/hono"
import { Hono } from "hono"
import * as module from "./functions"
 
const app = new Hono()
 
const methodHandler = createMethodHandler({ app })
createPrimServer({ module, methodHandler })
 
export default app

This example shows how Hono may be used from a serverless environment but you may reference Hono’s documentation to learn how to set it up in frameworks like Node and others.

We can test that this example is working by making a call over the command line (note that your server address will need to be changed):

curl "http://localhost:3000/prim"

You may also choose a compatible method plugin:

Report an Issue