Comments (1)
Setup
Will you deploy this project to vercel? If so, how None
What should we use for this app? tRPC
Do you want to use SSR with tRPC? Yes
Description
When I try to use tRPC on the server I get the following error
Error: No QueryClient set, use QueryClientProvider to set one at useQueryClient (/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@trpc+serve_rgpicpkohfucgjiz66s4i2bely/node_modules/solid-trpc/dist/index.js:3050:11) at eval (/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@trpc+serve_rgpicpkohfucgjiz66s4i2bely/node_modules/solid-trpc/dist/index.js:3080:57) at Proxy.createMemo (file:///home/user/dev/test/node_modules/.pnpm/[email protected]/node_modules/solid-js/dist/server.js:83:9) at createBaseQuery (/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@trpc+serve_rgpicpkohfucgjiz66s4i2bely/node_modules/solid-trpc/dist/index.js:3080:40) at createQuery (/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@trpc+serve_rgpicpkohfucgjiz66s4i2bely/node_modules/solid-trpc/dist/index.js:3220:10) at Object.useQuery (/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@trpc+serve_rgpicpkohfucgjiz66s4i2bely/node_modules/solid-trpc/dist/index.js:3398:12) at eval (/node_modules/.pnpm/[email protected]_@[email protected]_@trpc+clie [email protected]_@trpc+serve_rgpicpkohfucgjiz66s4i2bely/node_modules/solid-trpc/dist/index.js:1269:26) at Object.apply (/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@trpc+serve_rgpicpkohfucgjiz66s4i2bely/node_modules/solid-trpc/dist/index.js:646:14) at Object.$$serverHandler0 (/src/routes/index.tsx:29:60) at execute (/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/solid-start/server/server-functions/server.ts:198:37) at Object.fn (/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/solid-start/server/server-functions/server.ts:210:12) at Module.handleServerRequest (/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/solid-start/server/server-functions/server.ts:173:34) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async eval (/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/solid-start/server/middleware.ts:41:30) at async eval (/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/solid-start/api/middleware.ts:33:12) at async eval (/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/solid-start/entry-server/StartServer.tsx:45:12) at async devFetch (file:///home/user/dev/test/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/solid-start/dev/server.js:46:12) at async startHandler (file:///home/user/dev/test/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/solid-start/dev/server.js:115:20)
Code Snippet
import { type VoidComponent } from 'solid-js'; import { redirect } from 'solid-start'; import { createServerAction$ } from 'solid-start/server'; import { trpc } from '~/utils/trpc'; const Home: VoidComponent = () => { // const hello = trpc.example.hello.useQuery(() => ({ name: 'from tRPC' })); const [_, { Form }] = createServerAction$(async (formData: FormData) => { try { const hello = trpc.example.hello.useQuery(() => ({ name: 'from tRPC' })); console.log(hello?.data); } catch (error) { console.log(error); } const name = formData.get('name'); console.log(name); return redirect('/'); }); return ( <main> {/* <p>{hello.data ?? 'Loading tRPC query'}</p> */} <Form> <input type="text" name="name" /> <input type="submit">Submit</input> </Form> </main> ); }; export default Home;
Is there a step I am missing?
This is not a valid way of calling a hook. You cannot use a hook inside of server context, this will have to be declared within the page / client component. Might have serverSideHelpers in the future
from create-jd-app.
Related Issues (20)
- trpc query options works not as expected 🧐 HOT 1
- Resolutions Errors HOT 2
- npm install error HOT 2
- [Question] Using within createServerData$ HOT 1
- When generating TRPC app, it uses a dependency that is not open-source (source available anywhere) HOT 2
- Not working in Mono/Turborepo HOT 1
- Uncaught ReferenceError: global is not defined HOT 1
- TypeError: __vite_ssr_import_0__.SolidAuth is not a function HOT 5
- (solid query/trpc) does not hydrate properly HOT 9
- query client should not be shared between requests HOT 2
- Broken CLI HOT 1
- Unexpected token < in JSON at position 0 HOT 1
- AuthJs on Cloudflare Workers HOT 2
- Error: "route.outlet is not a function" on creating a new jd app HOT 2
- route.outlet is not a function HOT 2
- Application not starting HOT 1
- Latest Version of Tanstack Solid Query Breaking CreateJD HOT 5
- Private procedures throwing unauthorized issue HOT 3
- Can't import serverEnv from anything imported client-side (e.g. Co-located PRPC query + resolver) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from create-jd-app.