@elevora/react
v0.1.15
Published
Official SDK for Elevora's public API
Downloads
959
Maintainers
Readme
@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
- Wrap your application with the
ElevoraProvider
:
tsx
import { ElevoraProvider } from '@elevora/react';
function App() {
return (
<ElevoraProvider campaignSlug="your-campaign-slug">
<YourApp />
</ElevoraProvider>
);
}
- 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 campaignchildren
: React nodes to be wrapped by the provider
useElevora Hook
Returns an object containing:
campaignSlug
: Current campaign identifierrewards
: Campaign details and rewards informationuserEntry
: Current user's entry informationsetToken
: Function to set the authentication tokenisConnected
: Boolean indicating if user is authenticated
useWeb3Login Hook
Returns an object containing:
login
: Function to initiate Web3 loginisConnected
: Boolean indicating if wallet is connectedaddress
: 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