2022-05-17 16:52:50 -07:00
2022-05-17 16:50:41 -07:00
2022-05-17 16:52:50 -07:00
2022-05-16 01:55:10 -07:00
2022-05-17 08:57:07 -07:00
2022-05-17 14:25:03 -07:00
2022-05-17 14:25:03 -07:00
2022-05-17 14:25:03 -07:00
2022-05-17 16:26:53 -07:00
2022-05-17 14:25:03 -07:00
2022-05-17 16:50:41 -07:00
2022-05-17 14:25:03 -07:00

tRPC-Nuxt

Version

End-to-end typesafe APIs with tRPC.io in Nuxt applications.

Install

npm i trpc-nuxt -D
// nuxt.config.ts
import { defineNuxtConfig } from 'nuxt'

export default defineNuxtConfig({
  modules: ['trpc-nuxt'],
})

Usage

Create your tRPC routes and context under ~/trpc/index.ts:

// ~/trpc/index.ts
import type { inferAsyncReturnType } from '@trpc/server'
import * as trpc from '@trpc/server'

export const router = trpc
  .router<inferAsyncReturnType<typeof createContext>>()
  // queries and mutations...
  .query('hello', {
    resolve: () => 'world',
  })

// optional
export const createContext = () => {
  // ...
  return {
    /** context data */
  }
}

// optional
export const responseMeta = () => {
  // ...
  return {
    // { headers: ... }
  }
}

Use the client like so:

<script setup lang="ts">
const client = useClient()
const data = await client.query('hello')
console.log(data) // => 👈 world
</script>

Composables

Composables are auto-imported.

###useTrpcQuery(path, input)

Description
No description provided
Readme MIT 3.1 MiB
Languages
TypeScript 88.1%
Vue 11.9%