Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=your_wallet_connect_project_id

2. Add the package to your Tailwind CSS configuration:

For Tailwind CSS v3:

```ts
// tailwind.config.ts
import type { Config } from "tailwindcss";
Expand All @@ -36,6 +38,14 @@ const config: Config = {
export default config;
```

For Tailwind CSS v4:

Add this line to your CSS entry point (e.g., `app/globals.css`):

```css
@source "../node_modules/@everipedia/iq-login";
```

3. Wrap your application with the IqLoginProvider in your layout file:

```tsx
Expand Down
7 changes: 4 additions & 3 deletions src/config/iq-login.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if (!WEB_3_AUTH_CLIENT_ID) {

export interface IqLoginConfig {
wagmiConfig: Config;
web3AuthInstance: Web3AuthModal.Web3Auth;
web3AuthInstance: Web3AuthModal.Web3Auth | null;
chains: [Chain, ...Chain[]];
}

Expand All @@ -42,10 +42,11 @@ export function createIqLoginConfig(
chains.map((chain) => [chain.id, http()]),
);

const web3AuthInstance = createWeb3AuthInstance(chains[0]);
const web3AuthInstance =
typeof window !== "undefined" ? createWeb3AuthInstance(chains[0]) : null;

const connectors =
typeof window !== "undefined"
web3AuthInstance && typeof window !== "undefined"
? [
injected(),
walletConnect({
Expand Down
6 changes: 5 additions & 1 deletion src/hooks/use-web-3-auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ export function Web3AuthProvider({
chains,
}: {
children: React.ReactNode;
web3AuthInstance: Web3Auth;
web3AuthInstance: Web3Auth | null;
chains: Chain[];
}) {
const [user, setUser] = useState<Partial<UserInfo> | null>(null);
const [chainsAdded, setChainsAdded] = useState(false);

useEffect(() => {
if (!web3AuthInstance) {
return;
}

web3AuthInstance.on("connected", async () => {
setUser(await web3AuthInstance.getUserInfo());

Expand Down
Loading