{"id":22489457,"url":"https://github.com/michealroberts/usetrpc","last_synced_at":"2025-11-01T16:30:28.443Z","repository":{"id":38309165,"uuid":"496605089","full_name":"michealroberts/usetrpc","owner":"michealroberts","description":"A composables Vue 3 library for using a tRPC.io client.","archived":false,"fork":false,"pushed_at":"2022-06-07T13:43:52.000Z","size":49,"stargazers_count":52,"open_issues_count":0,"forks_count":2,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-02-14T16:46:43.048Z","etag":null,"topics":["trpc","typescript","vue3","vue3-composition-api","vue3-typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/michealroberts.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-26T12:07:38.000Z","updated_at":"2024-12-22T10:59:59.000Z","dependencies_parsed_at":"2022-07-14T03:20:38.996Z","dependency_job_id":null,"html_url":"https://github.com/michealroberts/usetrpc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michealroberts%2Fusetrpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michealroberts%2Fusetrpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michealroberts%2Fusetrpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michealroberts%2Fusetrpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michealroberts","download_url":"https://codeload.github.com/michealroberts/usetrpc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239301979,"owners_count":19616451,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["trpc","typescript","vue3","vue3-composition-api","vue3-typescript"],"created_at":"2024-12-06T17:19:54.733Z","updated_at":"2025-11-01T16:30:28.209Z","avatar_url":"https://github.com/michealroberts.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# useTRPC\n\nA composables Vue 3 library for using a tRPC.io client, bringing end-to-end typesafe APIs to Vue 3.\n\nPlease reference the tRPC documenation (https://trpc.io/docs/)[https://trpc.io/docs/] before using this library.\n\n**N.B**. *This library is a work in progress and is not yet ready for usage in production.*\n\n## Installation\n\n```bash\nnpm install @trpc/vue\n```\n\nor\n\n```bash\nyarn(pnpm) add @trpc/vue\n```\n\nThen, you can simply import what you need:\n\n```\nimport { useTRPCClient, useTRPCQuery, useTRPCMutation } from '@trpc/vue'\n```\n\n## Usage\n\n### Define AppRouter\n\nBe sure to define a tRPC router of type `AppRputer`, e.g.:\n\n```ts\nimport * as trpc from '@trpc/server';\n\nexport const appRouter = trpc\n  .router\u003cContext\u003e()\n  .query('all', {\n    resolve({ ctx }) {\n      return {\n        greeting: `world`,\n      };\n    },\n  });\n  \nexport type AppRouter = typeof appRouter\n```\n\nPlease see [https://trpc.io/docs/router](https://trpc.io/docs/router) for further explanation of defining the router and the `AppRouter` type.\n\n### Instantiating a tRPC client:\n\n```ts\nimport { useTRPCClient } from '@trpc/vue'\n\n// import your router, e.g.:\nimport type { AppRouter } from './server/router'\n\nconst { client } = useTRPCClient\u003cAppRouter\u003e({\n  url: 'http://localhost:3000/trpc'\n})\n```\n\n### Making a tRPC Query\n\n```ts\nimport { TRPCClient } from '@trpc/client'\n\nimport type { AppRouter } from '@observerly/pleiades'\n\nimport { useTRPCQuery } from '@trpc/vue'\n\nexport const useTelescopes = (client: TRPCClient\u003cAppRouter\u003e) =\u003e {\n  const telescopes = useTRPCQuery(client, ['telescopes.all'])\n\n  return {\n    telescopes\n  }\n}\n```\n\n## To-Do\n\n- [ ] Publish as npm public package\n- [X] Add useClient() composable\n- [ ] Add comprehensive usage tests for useClient()\n- [X] Add useQuery() composable\n- [X] Improve type inference for useQuery()\n- [ ] Add comprehensive usage tests for useQuery()\n- [X] Add useMutation()\n- [ ] Add comprehensive usage tests for useMutation()\n- [ ] Add useSubscription()\n- [ ] Add comprehensive usage tests for useSubscription()\n- [ ] Add usage documentation and demo examples.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichealroberts%2Fusetrpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichealroberts%2Fusetrpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichealroberts%2Fusetrpc/lists"}