New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@privy-io/expo

Package Overview
Dependencies
Maintainers
8
Versions
749
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@privy-io/expo

Expo client for the Privy Auth API

  • 0.1.2-beta-20231024142926
  • npm
  • Socket score

Version published
Weekly downloads
1.2K
decreased by-76.13%
Maintainers
8
Weekly downloads
 
Created
Source

@privy-io/expo

Usage

// Required pollyfils
import 'react-native-get-random-values';
import '@ethersproject/shims';

import React from 'react';

import {PrivyProvider} from '@privy-io/expo';

// Your components
import {HomeScreen} from './Homescreen';

export default function App() {
  return (
    <PrivyProvider appId={'<your-privy-app-id>'}>
      <HomeScreen />
    </PrivyProvider>
  );
}

Auth

import {useLoginWithEmail} from '@privy-io/expo';

export function LoginScreen() {
  const [email, setEmail] = useState('');
  const [code, setCode] = useState('');

  const {sendCode, loginWithCode} = useLoginWithEmail();

  return (
    <View style={styles.container}>
      <Text>Login</Text>

      <TextInput value={email} onChangeText={setEmail} placeholder="Email" inputMode="email" />
      <Button onPress={() => sendCode({email})}>Send Code</Button>

      <TextInput value={code} onChangeText={setCode} placeholder="Code" inputMode="numeric" />
      <Button onPress={() => loginWithCode({code})}>Login</Button>
    </View>
  );
}

Embedded Wallets

export function SignMessageScreen() {
  const [signature, setSignature] = useState<string | null>(null);

  const {user} = usePrivy();
  const wallet = useEmbeddedWallet();
  const address = getUserEmbeddedWallet(user)?.address;

  const signMessage = async (provider: PrivyEmbeddedWalletProvider) => {
    const sig = await provider.request({
      method: 'personal_sign',
      params: ['Hello Privy!', account?.address],
    });

    setSignature(sig);
  };

  return (
    <View style={styles.container}>
      <Text>Sign</Text>

      {wallet.status === 'connected' && (
        <Button onPress={() => signMessage(wallet.provider)}>Sign Message</Button>
      )}

      {signature && <Text>{signature}</Text>}
    </View>
  );
}

Keywords

FAQs

Package last updated on 24 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc