-
Notifications
You must be signed in to change notification settings - Fork 685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bug] pnpm build error #2215
Comments
Remove any client side import from layout.tsx resolves the problem. Including the If you need the ssr logic, check the other code which can only works in client mode, in my case, I should add 'use client' in my |
You may still need the ssr functionality to be work thus result in this solution below: import { mainnet, scroll, sepolia } from 'viem/chains'
import { cookieStorage, createConfig, createStorage, http } from 'wagmi'
let config = null
if (typeof window !== 'undefined') {
;(async () => {
const [{ connectorsForWallets }, { walletConnectWallet }] = await Promise.all([import('@rainbow-me/rainbowkit'), import('@rainbow-me/rainbowkit/wallets')])
const connectors = connectorsForWallets(
[
{
groupName: 'Mobile compat',
wallets: [walletConnectWallet],
},
],
{
appName: 'dapp',
projectId: 'edd4a3a6d5256ef234836b3b30a2c000',
},
)
config = createConfig({
chains: [mainnet, sepolia, scroll],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
[scroll.id]: http(),
},
ssr: true,
storage: createStorage({ storage: cookieStorage }),
connectors,
})
})()
}
export { config } |
The wagmi ssr cookie need to be work on server side and the config of rainbowkit should be only run in client side. Thus will lead a build error if mixed. Detailed here: rainbow-me/rainbowkit#2215
Reopen the issue, if it can only read the config in the client component, the ssr workflow won't work properly, meaning the flash of "empty" data before hydration will happen. // this line of code should run in server component to resolve the flash issue
// however, rainbowkit like connectorsForWallets can only be used in client side, thus the config can't read from server here
const basicInitialState = cookieToInitialState(config, headers().get('cookie')) |
The final changes I did: Get rid of the ssr workflow as the rainbowkit can only be running in the client component. It will always be a flash of "empty" in that case. Please consider and support this ssr case🙏 |
Is there an existing issue for this?
RainbowKit Version
^2.1.7
wagmi Version
^2.12.17
Current Behavior
Error when run
pnpm build
on a refresh new nextjs project usepnpm create next-app@rc --turbo
with ts, app router, without src folder.Installed deps with:
pnpm add @rainbow-me/rainbowkit wagmi [email protected] @tanstack/react-query
Use code below and run
pnpm build
will get error:code here:
Expected Behavior
No response
Steps To Reproduce
No response
Link to Minimal Reproducible Example (CodeSandbox, StackBlitz, etc.)
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: