@web3-onboard/solid for SolidStart
I want to use this package on my solidstart app but there are many issues.
First I need ssr disabled otherwise I get error
localstorage is not defined
on app start
Sometimes it runs the sign message twice
It won't redirect to /dashboard as expected and says localstorage is not defined
see files below
repo of package: https://github.com/thirdweb-dev/web3-onboard12 Replies
that's because
localStorage
isn't available on the server-side.
this library is client-side only, so you can use it in a component with clientOnly()
or wrap it around a check.
'localStorage' in window
or simply window
Yeah I figured that was the reason... So I can still use it you say?
Because there's init
On entry client I just do isserver?
Will test
yes, the important part is ensuring the lib will only run on the client-side. There are many ways to make that
yeah so I've enable again ssr since we can actually make the lib client only
here's my code Context.tsx
app.config.ts
entry-client.tsx
and I get 503 Server Unavailable
ReferenceError: localStorage is not defined
what am I missing?
useOnboard
seems to still be initialized in the serveryeah so how do I run it only on client? what's the best way?
I'm not super familiar wiht the app and I have never used the lib, but perhaps move it out of the page component and wrap its dedicate one in a
clientOnly
wrapper.yeah u mean moving out of the context and have it as function for web3 things with createEffect? but components must have jsx return value right? if I call the client only comp in app.tsx with {myclientonly()} will it work?
the clientOnly is a dynamic import that will only resolve on the client. On the server it will work as a passthrough - so if there's anything in your rendering logic that depend on it, things will break
ok I get error
Malformed server function stream header: !DOCTYPE h
my web3.tsx comp
I call it in app.tsx const Web3LoginComp = clientOnly(() => import("./components/Web3"));
Hard to spot the issue looking at the snippets.
If the clinetOnly import is like you pasted, and the usage is like below - that isn't exactly the problem.
maybe start with a more minimal implementation and see what part of the lib/integration is causing it
yeah there's the <Auth> wrapper just like in with-auth example but it's the same
maybe there's an error because I useAction inside a client only comp??
my login is just
definitely issue is the server action
I tested to removed it and it works
@Atila yeah solved issue just some bad config with db thanks
only small issue left is that it runs 2 times
this part
const address = await sign(wallet.provider);
a reactivity issue?
if I console.log wallet in login it logs wallet 2 times