ton-connect / sdk

SDK for TON Connect 2.0 — a comprehensive communication protocol between wallets and apps in TON ecosystem
Apache License 2.0
330 stars 96 forks source link

[UI-REACT]: window.localStorage is undefined. localStorage is required for TonConnectUI #86

Closed alice-ion closed 1 year ago

alice-ion commented 1 year ago

Hi guys!

Describe the bug Using ui-react-2.0.0-beta.1 & Next.js returns the error window.localStorage is undefined. localStorage is required for TonConnectUI Error.

To Reproduce Steps to reproduce the behavior:

  1. Create new next.js project npx create-next-app@latest nextjs-blog --use-npm --example "https://github.com/vercel/next-learn/tree/main/basics/learn-starter"
  2. cd nextjs-blog
  3. Add "@tonconnect/ui-react": "^2.0.0-beta.1" to depencencies in packages.json
  4. Install depencencies with yarn install
  5. Add import { TonConnectUIProvider, TonConnectButton } from "@tonconnect/ui-react"; in pages/index.js
  6. Run yarn dev
  7. See error

Expected behavior No errors should be returned from yarn dev or yarn build

Screenshots

Additional context I think checkLocalStorageExists can be removed. https://github.com/ton-connect/sdk/blob/9e999123d68a7725bd890a181850063fd28f429c/packages/ui/src/app/utils/web-api.ts#L96-L102

thyoondev commented 1 year ago

I have the same issue