0.5.5 • Published 6 months ago

@crossmint/client-sdk-react-native-ui v0.5.5

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
6 months ago

Crossmint React Native SDK

This package provides a React Native UI for integrating Crossmint authentication and wallet functionality into your mobile apps.

Installation

pnpm add @crossmint/client-sdk-react-native-ui expo-secure-store expo-web-browser

Authentication with Secure Storage

The React Native SDK uses Expo's SecureStore for secure, encrypted storage of authentication tokens. This provides a platform-native secure storage solution that encrypts sensitive data on the device.

Using the Default Secure Storage

The CrossmintAuthProvider uses SecureStorage by default:

import { CrossmintProvider, CrossmintAuthProvider } from "@crossmint/client-sdk-react-native-ui";

export default function App() {
  return (
    <CrossmintProvider
      apiKey="YOUR_API_KEY"
    >
      <CrossmintAuthProvider>
        {/* Your app content */}
      </CrossmintAuthProvider>
    </CrossmintProvider>
  );
}

Authentication Hooks

Once the providers are set up, you can use the authentication hooks in your components:

import { useCrossmintAuth } from "@crossmint/client-sdk-react-native-ui";

function ProfileScreen() {
  const { user, status, logout, login } = useCrossmintAuth();

  if (status === "logged-out") {
    return (
      <View>
        <Button
          title="Sign in with Google"
          onPress={() => login("google")}
        />
      </View>
    );
  }

  return (
    <View>
      <Text>Welcome, {user?.email}</Text>
      <Button title="Logout" onPress={logout} />
    </View>
  );
}

Custom Storage Provider

If you need to implement a custom storage solution, you can implement the StorageProvider interface and pass it to the CrossmintAuthProvider:

import { CrossmintAuthProvider, type StorageProvider } from "@crossmint/client-sdk-react-native-ui";

// Implement your custom storage provider
class CustomStorage implements StorageProvider {
  async get(key: string): Promise<string | undefined> {
    // Your implementation
  }

  async set(key: string, value: string, expiresAt?: string): Promise<void> {
    // Your implementation
  }

  async remove(key: string): Promise<void> {
    // Your implementation
  }
}

// Use your custom storage provider
function App() {
  const customStorage = new CustomStorage();

  return (
    <CrossmintProvider apiKey="YOUR_API_KEY">
      <CrossmintAuthProvider customStorageProvider={customStorage}>
        {/* Your app content */}
      </CrossmintAuthProvider>
    </CrossmintProvider>
  );
}

For more detailed documentation, please visit the Crossmint Developer Docs.

0.5.5

6 months ago

0.5.4

6 months ago

0.5.3

6 months ago

0.5.2

6 months ago

0.5.1

6 months ago

0.5.0

6 months ago

0.4.20

6 months ago

0.4.19

7 months ago

0.4.18

7 months ago

0.4.17

7 months ago

0.4.16

7 months ago

0.4.15

7 months ago

0.4.14

7 months ago

0.4.13

7 months ago

0.4.12

7 months ago

0.4.11

7 months ago

0.4.10

7 months ago

0.4.9

7 months ago

0.4.8

7 months ago

0.4.7

7 months ago

0.4.6

7 months ago

0.4.5

7 months ago

0.4.4

7 months ago

0.4.3

7 months ago

0.4.2

7 months ago

0.4.1

7 months ago

0.4.0

7 months ago

0.3.10

8 months ago

0.3.9

8 months ago

0.3.8

8 months ago

0.3.7

8 months ago

0.3.6

8 months ago

0.3.5

8 months ago

0.3.4

8 months ago

0.3.3

8 months ago

0.3.2

8 months ago

0.3.1

8 months ago

0.3.0

8 months ago

0.2.0

8 months ago

0.1.2

8 months ago

0.1.1

8 months ago

0.1.0

8 months ago