Giter Site home page Giter Site logo

anywhere's Introduction

@react-native-anywhere/anywhere

@react-native-anywhere/anywhere is a build tool to help you expose browserified libraries to React Native.

There are a lot of really amazing libraries such as Web3 that we don't get to use in React Native because they assume the availability of core Node.js libraries such as crypto.

This tool can be used to compile compatible implementations of these libraries for the React Native runtime.

๐Ÿš€ Getting Started

Using yarn:

yarn add @react-native-anywhere/anywhere

Next, append the following command to your postinstall script in your package.json:

"scripts": {
+ "postinstall": "npx @react-native-anywhere/anywhereify"
}

Finally, declare an anywhere.config.json at the root of your project. Here, you declare the libraries and naming conventions you'd like to expose to the React Native runtime:

{
  "exports": [
    { "name": "@react-native-anywhere/polyfill-base64" },
    { "name": "web3-providers-http", "alias": "Web3HttpProvider" },
    { 
      "name": "@opengsn/gsn",
      "alias": "OpenGSN",
      "exports": [
        { "name": "dist/RelayProvider", "alias": "RelayProvider" },
        { "name": "dist/GSNConfigurator", "alias": "GSNConfigurator" }
      ]
    }
  ]
}

Now you're all set! โœจ

Whenever you reinstall your project, npx @react-native-anywhere/anywhereify will recompile the dependencies defined in your anywhere.config.json into a React Native compatible format. Once this is done, they will become available via imports:

import { Web3HttpProvider, OpenGSN } from "@react-native-anywhere/anywhere";
const { RelayProvider, GSNConfigurator } = OpenGSN;

You can check out some Example Projects here.

โœŒ๏ธ License

MIT

anywhere's People

Contributors

cawfree avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.