Vanilla
The vanilla client allows you to consume your API on the frontend. This client is the minimal core and it is recommended that you use the React or Solid integration for building application.
To get started first install the minimal runtime package.
Next you need to export the Typescript bindings from your rspc::Router by using either export_ts_bindings or export_ts.
Then you can use the @rspc/client package to consume your API.
Transports
rspc has multiple different transports which can be used. These dictate how the frontend is able to talk with the backend.
Fetch Transport
Transport is built on the standard Fetch API.
GET or POST?
rspc uses:
GETrequests for queriesPOSTrequests for mutations
Important: While rspc primarily uses GET requests for queries,
it may also use POST requests for queries in certain scenarios (similar to how GraphQL operates).
Mutations will always use POST requests and will never use GET.
This behavior is an implementation detail and isn't guaranteed to remain the same in the future.
Custom Fetch implementation
Fetch Authentication
Guide coming soon...
Websocket Transport
Transport build on the standard WebSocket API. This uses HTTP GET and POST requests under the hood.
Websocket Authentication
Guide coming soon...
-- TODO: Discuss Single Flight Mutations
Last updated on