Working tRPC on websockets
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"
|
||||
import { httpBatchLink } from "@trpc/client"
|
||||
import { createWSClient, wsLink } from "@trpc/client"
|
||||
import { ReactNode, useState } from "react"
|
||||
import { trpc } from "./trpc"
|
||||
|
||||
@@ -12,13 +12,16 @@ export interface TRPCClientProviderProps {
|
||||
export function TRPCClientProvider({ children }: TRPCClientProviderProps) {
|
||||
|
||||
const [queryClient] = useState(new QueryClient())
|
||||
const [wsClient] = useState(createWSClient({ url: "ws://localhost:3001" }))
|
||||
|
||||
const [trpcClient] = useState(trpc.createClient({
|
||||
links: [
|
||||
httpBatchLink({
|
||||
url: "http://localhost:8080/rpc",
|
||||
headers: async () => ({}),
|
||||
})
|
||||
// httpBatchLink({
|
||||
// url: "http://localhost:8080/rpc",
|
||||
// headers: async () => ({}),
|
||||
// }),
|
||||
|
||||
wsLink({ client: wsClient }),
|
||||
]
|
||||
}))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user