Introduction

Welcome to pRPC!

pRPC is an open sourceSolidStart utility library to make working with server$ easier.

About

Using pRPC you will be able to write server code in frontend files in SolidStart and connect your functions with tanstack query & mutation by default. For instance:

import { middleware$, query$, response$, error$ } from '@prpc/solid'
import { type NextPage } from 'next'
import { z } from 'zod'

const testMw = middleware$(async ({ request$ }) => {
  const ua = request$.headers.get('user-agent')
  console.log('middleware called on server ', ua)
  if (ua?.includes('bot')) {
    return error$('Bots are not allowed')
  }
  return {
    ua,
  }
})

const myQuery = query$({
  queryFn: ({ request$, ctx$, payload }) => {
    console.log(
      'queryFn called on server ',
      ctx$.ua === request$.headers.get('user-agent'),
      payload
    )
    return response$(payload.num / 2)
  },
  key: 'testQuery',
  middlewares: [testMw],
  schema: z.object({
    num: z.number(),
  }),
})

Getting Started