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

@magic-sdk/react-native-expo

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@magic-sdk/react-native-expo

Passwordless authentication for React Native (Expo).

17.1.0-canary.490.4602563296.0
Version published
Weekly downloads
1.1K
162.69%
Maintainers
22
Weekly downloads
 
Created

✨ Magic Authentication JavaScript SDK

<MagicLabs>

Magic empowers developers to protect their users via an innovative, passwordless authentication flow without the UX compromises that burden traditional OAuth implementations.

License · Changelog · Contributing Guide

⚠️ Major Change: Package Split Beta ⚠️

Please note that splitting the Expo and Bare React Native Magic package is a part of a beta release. Take whatever precautions necessary to verify use before installing on your production application. As always, in the case something goes awry, you may open an issue and revert your package to the previous pre-split stable version magic-sdk/react-native@x.x.x.

📖 Documentation

See the developer documentation to learn how you can master the Magic SDK in a matter of minutes.

🔗 Installation

Integrating your app with Magic will require our client-side NPM package:

# Via NPM:
npm install --save @magic-sdk/react-native-expo
npm install --save react-native-webview@^8.0.0 # Required Peer Dependency
npm install --save react-native-safe-area-context # Required Peer Dependency

# Via Yarn:
yarn add @magic-sdk/react-native-expo
yarn add react-native-webview@^8.0.0 # Required Peer Dependency
yarn add react-native-safe-area-context # Required Peer Dependency

⚡️ Quick Start

Sign up or log in to the developer dashboard to receive API keys that will allow your application to interact with Magic's authentication APIs.

Then, you can start authenticating users with just one method!

import React from 'react';
import { Magic } from '@magic-sdk/react-native-expo';
import { SafeAreaProvider } from 'react-native-safe-area-context';

const magic = new Magic('YOUR_API_KEY');

export default function App() {
 return <>
     <SafeAreaProvider>
        {/* Render the Magic iframe! */}
        <magic.Relayer />
        {...}
     </SafeAreaProvider>
  </>
}
// Somewhere else in your code...
await magic.auth.loginWithMagicLink({ email: 'your.email@example.com' });

⁠⁠👉 Check out some of our React Native Demo apps for inspiration! 👀

👀 SafeAreaView

Please note that as of v14.0.0 our React Native package offerings wrap the <magic.Relayer /> in react-native-safe-area-context's <SafeAreaView />. To prevent any adverse behavior in your app, please place the Magic iFrame React component at the root view of your application wrapped in a SafeAreaProvider as described in the documentation.

🙌🏾 Troubleshooting

Symlinking in Monorepo w/ Metro

For React Native projects living within a monorepo that run into the following TypeError: Undefined is not an object error:

Screenshot 2022-11-23 at 12 19 19 PM

When attempting to import Magic, take note that the React Native metro bundler doesn’t work well with symlinks, which tend to be utilized by most package managers.

For this issue consider using Microsoft's rnx-kit suite of tools that include a plugin for metro that fixes this symlink related error.

FAQs

Package last updated on 04 Apr 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