0.1.8 • Published 10 months ago

@elevora/web3 v0.1.8

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

@elevora/react

⚠️ Warning: This SDK is currently under active development and may undergo significant changes. Use with caution in production environments.

Official React SDK for Elevora's public API. This SDK provides easy integration with Elevora's waitlist and referral system.

Requirements

Signup on elevora.app and setup a campaign

Installation

npm install @elevora/react axios @tanstack/react-query react

Quick Start

  1. Wrap your application with the ElevoraProvider:
tsx
import { ElevoraProvider } from '@elevora/react';

function App() {
    return (
        <ElevoraProvider campaignSlug="your-campaign-slug">
            <YourApp />
        </ElevoraProvider>
    );
}
  1. Use the useElevora hook in your components:
import { useElevora } from '@elevora/react';

function YourComponent() {
    const { rewards, userEntry, isConnected } = useElevora();
    return (
        <div>
            {isConnected ? (
            <p>Welcome back!</p>
            ) : (
            <p>Please sign in</p>
            )}
        </div>
    );
}

Web3 Integration

The SDK includes built-in support for Web3 authentication using the useWeb3Login hook:

import { useWeb3Login } from '@elevora/react';

function LoginComponent() {
    const { login, isConnected, address } = useWeb3Login({
        autoLogin: true // Optional: automatically attempts login when wallet is connected
    });

    return (
    <button onClick={login}>
        Connect Wallet
    </button>
    );
}

API Reference

ElevoraProvider

The main provider component that enables access to Elevora's functionality.

Props:

  • campaignSlug (required): The unique identifier for your campaign
  • children: React nodes to be wrapped by the provider

useElevora Hook

Returns an object containing:

  • campaignSlug: Current campaign identifier
  • rewards: Campaign details and rewards information
  • userEntry: Current user's entry information
  • setToken: Function to set the authentication token
  • isConnected: Boolean indicating if user is authenticated

useWeb3Login Hook

Returns an object containing:

  • login: Function to initiate Web3 login
  • isConnected: Boolean indicating if wallet is connected
  • address: Connected wallet address

Options:

  • autoLogin: Boolean to enable automatic login (default: true)

Types

The SDK exports all API types from the @elevora/react/schemas path:

import { PublicCampaignsDto, UserEntryPublicDto } from '@elevora/react/schemas';

Made with ❤️ by Thibault Mathian

0.1.8

10 months ago

0.1.7

10 months ago

0.1.6

10 months ago

0.1.5

10 months ago

0.1.4

10 months ago

0.1.3

10 months ago

0.1.2

11 months ago

0.1.1

11 months ago

0.1.0

11 months ago