Skip to main content

Getting Started

Installation#

Install library as npm module:

npm install @onekeyhq/connect

or

yarn add @onekeyhq/connect

Initialization#

ES6

import OneKeyConnect from '@onekeyhq/connect';

CommonJS

var OneKeyConnect = require('@onekeyhq/connect').default;

API methods#

Handling events#

Running local version (develop/stable)#

  • clone repository: git clone git@github.com:OneKeyHQ/connect.git
  • install node_modules: yarn
  • run localhost server: yarn dev

Initialize in project

OneKeyConnect.init({    connectSrc: 'https://localhost:8088/',    lazyLoad: true, // this param will prevent iframe injection until OneKeyConnect.method will be called    manifest: {        email: 'hi@onekey.so',        appUrl: 'https://onekey.so',    }})

Running local version (custom branch)#

In order to run a branch which isn't published to npm registry and this branch requires changes (mostly happened when new a method is added to OneKeyConnect interface)

  • git checkout custom-feature-branch
  • yarn build:npm

Install builded lib in your project:

Using yarn link#

  • cd ./npm && yarn link
  • Inside your project: yarn install @onekeyhq/connect

Using local files#

  • Inside your project: yarn install @onekeyhq/connect@file:/[local-path-to-repository]/npm