0.0.1-alpha.19 • Published 5 months ago

@radish-la/world-auth v0.0.1-alpha.19

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

@radish-la/world-auth

The react library for Worldchain.

Getting started

npm i @radish-la/world-auth jotai @worldcoin/minikit-js

Setting up validator

When using world we need to check if the current session is valid. Under the hood we use verifySiweMessage to verify if our stored session payload is a valid signed SIWE message.

We've added a small utility function to fasten this. Follow this steps:

  1. Create a file at root level (along with layout.tsx) with the following:
// session.tsx

"use server"

import { validateSession } from "@radish-la/world-auth/server"
export const validator = validateSession
  1. Define the World Auth Provider
// layout.tsx

import type { PropsWithChildren } from "react"
import { WorldAppProvider } from "@radish-la/world-auth"

import { validator } from "./session"

export default function RootLayout({ children }: PropsWithChildren) {
  return (
    <WorldAppProvider appName="YOUR_APP_NAME" withValidator={validator}>
      {children}
    </WorldAppProvider>
  )
}

Done 🥳. You're now ready to interact with the connected user and signin/signout the user too.


Usage

import { useWorldAuth } from "@radish-la/world-auth"

const { user, isConnected, isMiniApp, isConnecting, signIn, signOut } =
  useWorldAuth()

// isConnected: `true` when user and session is injected to MiniKit
// isConnecting: `true` if login modal is open
// signIn: request access to user information for mini app
// signOut: clean up the connected session
// isMiniApp: `true` when MiniKit is available in the browser

// To consume the connected user info you can pick values from:
// user.walletAddress // User's worldchain address
// user.username // Worldchain username
// user.profilePictureUrl // Custom profile picture `undefined` by default

🔍 See example next14 repo

0.0.1-alpha.19

5 months ago

0.0.1-alpha.18

7 months ago

0.0.1-alpha.17

7 months ago

0.0.1-alpha.16

7 months ago

0.0.1-alpha.15

7 months ago

0.0.1-alpha.14

7 months ago

0.0.1-alpha.13

7 months ago

0.0.1-alpha.12

7 months ago

0.0.1-alpha.11

7 months ago

0.0.1-alpha.10

7 months ago

0.0.1-alpha.9

7 months ago

0.0.1-alpha.8

7 months ago

0.0.1-alpha.7

7 months ago

0.0.1-alpha.6

7 months ago

0.0.1-alpha.5

7 months ago

0.0.1-alpha.4

7 months ago

0.0.1-alpha.3

7 months ago

0.0.1-alpha.2

7 months ago

0.0.1-alpha.1

7 months ago