@trezor/connect-mobile
TypeScript icon, indicating that this package has built-in type declarations

0.0.1-beta.1 • Public • Published

@trezor/connect-mobile

NPM

The @trezor/connect-mobile package provides an implementation of @trezor/connect which uses deep links to communicate with the Trezor Suite Lite app.

🚧 BETA version, work in progress 🚧

Currently the library is still under development, only supports read-only methods and does not communicate with the production Suite Lite app.

To run a dev version of the Suite mobile app follow the instructions in @suite-native/app

Using the Library

To use the library, you need to initialize it with the deeplinkOpen and deeplinkCallbackUrl settings.

import TrezorConnect from '@trezor/connect-mobile';

TrezorConnect.init({
    manifest: {
        email: 'developer@xyz.com',
        appUrl: 'http://your.application.com',
    },
    deeplinkOpen: url => {
        // eslint-disable-next-line no-console
        console.log('deeplinkOpen', url);
        Linking.openURL(url);
    },
    deeplinkCallbackUrl: Linking.createURL('/connect'),
});

To receive the deep link callback, you need to add a listener which will call TrezorConnect.handleDeeplink with the deep link URL.

useEffect(() => {
    const subscription = Linking.addEventListener('url', event => {
        TrezorConnect.handleDeeplink(event.url);
    });

    return () => subscription?.remove();
}, []);

Example

The Connect mobile example shows how to use the library in a React Native + Expo app.

Readme

Keywords

none

Package Sidebar

Install

npm i @trezor/connect-mobile

Weekly Downloads

57

Version

0.0.1-beta.1

License

See LICENSE.md in repo root

Unpacked Size

16.6 kB

Total Files

6

Last publish

Collaborators

  • prusnak
  • tsusanka-sl
  • trezor-ci
  • martin_varmuza