Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

nhevia/tRPC-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

8 Commits

Repository files navigation

Summary

This is a project to showcase runtime end-to-end type safety using tRPC.

It's composed of a backend server (server-api) using Node+Express and a React application (frontend) scaffolded with ViteJS.

Types are available in the frontend because the tRPC client can hit http://localhost:5000/trpc/queryname-like routes, defined in Express using a router adapter.

Usage

Note: this project uses worspaces, execute commands from root folder.

  1. Install dependencies:
    $ npm install

  2. Start both dev servers:
    $ npm start
    note: outputs will be mixed in the same terminal. Alternatively you can start each dev server from their own folder in separate terminals

  3. Go to http://localhost:3000 and you should see the returned data. These objects have type safety all the way from the backend, where they are declared. This is achieve using tRPC as a wrapper for tanstack/query (asynchronous store).

About

e2e type safety with tRPC

Topics

Resources

Stars

Watchers

Forks

Contributors

AltStyle によって変換されたページ (->オリジナル) /