import { createWSClient, splitLink, wsLink, createTRPCClient, httpLink } from '@trpc/client';
import type { AppRouter } from '@api/app';
import superjson from 'superjson';
export const client = createTRPCClient<AppRouter>({
links: [
splitLink({
condition: (op) => op.type === 'subscription',
true: wsLink({
client: createWSClient({
url: `ws://localhost:7000`,
}),
transformer: superjson,
}),
false: httpLink({
url: `http://localhost:7000`,
fetch(url, options) {
return fetch(url, {
...options,
credentials: 'include',
cache: 'no-store',
});
},
transformer: superjson,
}),
}),
],
});
import { createWSClient, splitLink, wsLink, createTRPCClient, httpLink } from '@trpc/client';
import type { AppRouter } from '@api/app';
import superjson from 'superjson';
export const client = createTRPCClient<AppRouter>({
links: [
splitLink({
condition: (op) => op.type === 'subscription',
true: wsLink({
client: createWSClient({
url: `ws://localhost:7000`,
}),
transformer: superjson,
}),
false: httpLink({
url: `http://localhost:7000`,
fetch(url, options) {
return fetch(url, {
...options,
credentials: 'include',
cache: 'no-store',
});
},
transformer: superjson,
}),
}),
],
});