29.17.0 • Published 21 days ago

@magic-sdk/react-native-bare v29.17.0

Weekly downloads
-
License
MIT
Repository
github
Last release
21 days ago

✨ 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.

⚠️ Removal of loginWithMagicLink() ⚠️

As of v19.0.0, passcodes (ie. loginWithSMS(), loginWithEmailOTP()) are replacing Magic Links (ie. loginWithMagicLink()) for all of our Mobile SDKs⁠. Learn more

📖 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-bare
npm install --save react-native-device-info # Required Peer Dependency
npm install --save @react-native-community/async-storage # Required Peer Dependency
npm install --save react-native-safe-area-context # Required Peer Dependency
npm install --save @react-native-community/netinfo # Required Peer Dependency

# Via Yarn:
yarn add @magic-sdk/react-native-bare
yarn add react-native-device-info # Required Peer Dependency
yarn add @react-native-community/async-storage # Required Peer Dependency
yarn add react-native-safe-area-context # Required Peer Dependency
yarn add @react-native-community/netinfo # 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-bare';
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.loginWithEmailOTP({ 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.

We have also added an optional backgroundColor prop to the Relayer to fix issues with SafeAreaView showing the background. By default, the background will be white. If you have changed the background color as part of your custom branding setup, make sure to pass your custom background color to magic.Relayer:

<magic.Relayer backgroundColor="#0000FF"/>

🙌🏾 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:

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.

Handling internet connection problems

When an app is opened without internet connection, any request to the Magic SDK will result in a rejection with a MagicSDKError:

{
  "code": "MODAL_NOT_READY",
  "rawMessage": "Modal is not ready."
}

It is good practice to use @react-native-community/netinfo to track the internet connection state of the device. For your convenience, we've also added a hook that uses this library behind the scenes:

import { useInternetConnection } from '@magic-sdk/react-native-expo';

const magic = new Magic('YOUR_API_KEY');

const connected = useInternetConnection()

useEffect(() => {
   if (!connected) {
       // Unomount this component and show your "You're offline" screen.
   }
}, [connected])

export default function App() {
   return <>
       <SafeAreaProvider>
           {/* Render the Magic iframe! */}
           <magic.Relayer />
           {...}
       </SafeAreaProvider>
   </>
}
29.17.0

21 days ago

29.16.0

22 days ago

29.15.0

28 days ago

29.14.0

29 days ago

29.13.0

1 month ago

29.12.0

2 months ago

29.11.0

2 months ago

29.10.0

2 months ago

29.8.0

2 months ago

29.9.0

2 months ago

29.7.0

2 months ago

29.6.0

2 months ago

29.2.0

4 months ago

29.2.1

3 months ago

29.3.0

3 months ago

29.0.5

5 months ago

29.0.6

5 months ago

29.0.3

5 months ago

29.0.4

5 months ago

29.1.0

4 months ago

29.4.0

3 months ago

29.5.0

3 months ago

29.0.2

8 months ago

29.0.1

8 months ago

29.0.0

8 months ago

28.0.0

8 months ago

27.0.0

8 months ago

25.0.0

9 months ago

26.0.0

9 months ago

24.0.0

9 months ago

23.1.1

9 months ago

23.1.0

9 months ago

23.0.1

10 months ago

23.0.0

10 months ago

22.5.0

11 months ago

22.4.1

11 months ago

22.4.0

11 months ago

21.0.2

1 year ago

21.0.1

1 year ago

21.0.3

1 year ago

21.0.0

1 year ago

20.2.0

1 year ago

21.1.1

1 year ago

21.1.0

1 year ago

20.3.1

1 year ago

20.3.0

1 year ago

22.0.0

1 year ago

19.6.0

1 year ago

20.4.0

1 year ago

22.1.1

1 year ago

22.1.0

1 year ago

19.5.0

1 year ago

22.2.1

1 year ago

22.2.0

1 year ago

19.4.1

1 year ago

19.4.0

1 year ago

19.4.2

1 year ago

22.2.2

1 year ago

19.3.0

1 year ago

22.3.0

12 months ago

22.3.4

12 months ago

22.3.2

12 months ago

21.1.1-ari-test

1 year ago

19.2.1

1 year ago

20.0.0

1 year ago

20.1.0

1 year ago

19.2.0

1 year ago

19.1.0

1 year ago

19.0.1

1 year ago

19.0.0

1 year ago

18.2.3

1 year ago

18.4.0

1 year ago

18.2.2

1 year ago

18.2.1

2 years ago

18.2.0

2 years ago

18.5.0

1 year ago

18.3.1

1 year ago

18.3.0

1 year ago

18.0.0

2 years ago

14.5.0

2 years ago

17.3.0

2 years ago

14.3.1-b8606a5

2 years ago

17.1.0

2 years ago

16.1.0

2 years ago

15.0.0

2 years ago

15.0.1

2 years ago

18.1.2

2 years ago

18.1.1

2 years ago

18.1.0

2 years ago

14.6.0

2 years ago

14.6.1

2 years ago

14.6.2

2 years ago

17.2.0

2 years ago

17.0.1

2 years ago

17.0.0

2 years ago

16.0.0

2 years ago

14.2.0

2 years ago

14.3.0

2 years ago

14.4.0

2 years ago

14.1.0

2 years ago

14.0.1-903c2bf

2 years ago

14.0.0

2 years ago

13.1.1

2 years ago

13.1.1-9591571-2

2 years ago

13.1.1-9591571

2 years ago

13.1.0

2 years ago

13.0.1

2 years ago

13.0.0

2 years ago

12.0.9

2 years ago

12.0.8

2 years ago

12.0.7

2 years ago

12.0.6

2 years ago

12.0.4

2 years ago

12.0.3

2 years ago

12.0.2

2 years ago

12.0.0

2 years ago