-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(client): setup
tRPC
in front-end (#15)
* fix(server): update import path for fetchExternalData * wip * feature(client): set-up `tRPC` in front-end
- Loading branch information
1 parent
5195a6d
commit 1806777
Showing
6 changed files
with
28 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
VITE_API_URL = http://localhost:3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,26 @@ | ||
import App from './app.tsx'; | ||
import { StrictMode } from 'react'; | ||
import { trpc } from './utils/trpc.ts'; | ||
import { createRoot } from 'react-dom/client'; | ||
import { httpBatchLink } from '@trpc/react-query'; | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
|
||
const queryClient = new QueryClient(); | ||
|
||
const trpcClient = trpc.createClient({ | ||
links: [ | ||
httpBatchLink({ | ||
url: import.meta.env.VITE_API_URL, | ||
}), | ||
], | ||
}); | ||
|
||
createRoot(document.getElementById('root')!).render( | ||
<StrictMode> | ||
<App /> | ||
<trpc.Provider client={ trpcClient } queryClient={ queryClient }> | ||
<QueryClientProvider client={ queryClient }> | ||
<App /> | ||
</QueryClientProvider> | ||
</trpc.Provider> | ||
</StrictMode> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import type { AppRouter } from '@server/index.ts'; | ||
import { createTRPCReact } from '@trpc/react-query'; | ||
|
||
export const trpc = createTRPCReact<AppRouter>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters