trpc_client 0.1.1 copy "trpc_client: ^0.1.1" to clipboard
trpc_client: ^0.1.1 copied to clipboard

A minimal trpc client for Dart and Flutter.

trpc_client #

A simple trpc client for Dart Applications. It's minimal, dependency-free (only depends on dart's own http library), and works perfectly with flutter.

Features #

  • Run Query and Mutate operations against your tRPC server (expressjs, Next.js, Cloudflare Worker, ...)

Usage #

You just need to instantiate the TRPCClient class with the trpc base endpoint. You can optionally pass headers:

final client = TRPCClient(
    baseUri: "https://example.com/trpc",
    headers: {"x-trpc-source": "Dart App"},
  );

I recommend using it with riverpod, to make authentication easier:

@riverpod
TRPCClient trpcClient(TrpcClientRef ref) {
  final sessionId = ref.watch(sessionIdProvider);

  final client = TRPCClient(
    baseUri: "https://example.com/trpc",
    headers: {"Authorization": "Bearer $sessionId"},
  );

  return client;
}

Additional information #

TOOD #

  • ❌ Better README.md
  • ❌ Support for batching
  • ❌ Write tests with real tRPC server
  • ❌ Linter Rules
  • ❌ Docs?
  • ❌ Somehow generate definitions from ts?

PR's are welcome :D

10
likes
0
points
38
downloads

Publisher

verified publisherwosher.co

Weekly Downloads

A minimal trpc client for Dart and Flutter.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

http

More

Packages that depend on trpc_client