Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@berty/gnonative

Package Overview
Dependencies
Maintainers
4
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@berty/gnonative

Develop for Gno using your app's native language

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

gnonative

Develop for Gno using your app's native language

API documentation

We created a Javascript object helper (useGno) that wraps the RPC API. The useGno object is defined in the GnoNative repo at /expo/src/hooks/use-gno.ts.

The RPC API documentation is avalaible in the Buf registry:

  • Documentation

Installation in Expo projects

Prerequisites

Please follow the general Build instructions in the main README and then:

make asdf.install_tools

Create new Expo app

npx create-expo-app my-app
cd my-app

Add the package to your npm dependencies

npm install @berty/gnonative

Customize the app

We prepared for you an example Hello World code.

Open App.js and replace the content by this:

import React, { useEffect, useState } from 'react';
import { StyleSheet, Text, View } from 'react-native';

import * as Gnonative from '@berty/gnonative';

export default function App() {
  const gno = Gnonative.useGno();
  const [greeting, setGreeting] = useState('');

  useEffect(() => {
    const greeting = async () => {
      try {
        // sync Hello function
        setGreeting(await gno.hello('Gno'));

        // async Hello function
        for await (const res of await gno.helloStream('Gno')) {
          console.log(res.greeting);
        }
      } catch (error) {
        console.log(error);
      }
    };
    greeting();
  }, []);

  return (
    <View style={styles.container}>
      <Text>Hey {greeting}</Text>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

Run the app

# Re-generate the native project directories from scratch
npx expo prebuild --clean
# Run the example app on Android
npx expo run:android
# Run the example app on iOS
npx expo run:ios

Installation in bare React Native projects

For bare React Native projects, you must ensure that you have installed and configured the expo package before continuing.

Keywords

FAQs

Package last updated on 05 Apr 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc