LogoRobo.js
TemplatesDiscord activities

tRPC

A Discord Activity template with tRPC for type-safe APIs.

tRPC

A Discord Activity template using tRPC for end-to-end type-safe APIs.

Getting Started

Create a project with this template:

npx create-robo@next <project-name> --template discord-activities/react-trpc-ts

Then navigate into your project directory:

cd <project-name>

Run development mode:

npm run dev

Features

  • tRPC pre-configured
  • End-to-end type safety
  • React Query integration
  • TypeScript support

How It Works

Define your API procedures in the server and call them from the client with full type safety:

vite.mjs
.env
// Server
export const appRouter = router({
  hello: publicProcedure.query(() => 'Hello, world!')
})

// Client
const { data } = trpc.hello.useQuery()
// Server
export const appRouter = router({
  hello: publicProcedure.query(() => 'Hello, world!')
})

// Client
const { data } = trpc.hello.useQuery()

Hosting

npm run deploy

On this page