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

@onbeam/react

Package Overview
Dependencies
Maintainers
2
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onbeam/react

You need to provide a JWT token to consume the API. You will be able to obtain this user-specific JWT token after your user has logged in on your application.

  • 0.4.5-beta
  • unpublished
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
2
Weekly downloads
 
Created
Source

You need to provide a JWT token to consume the API. You will be able to obtain this user-specific JWT token after your user has logged in on your application.

Depending on your preferred storage solution, you will need to either pass a token prop to the provider on the initial render, or use the setToken handler returned from the useBeam() hook.

Option 1: Providing the token manually (initial render)

'use client';

import { Game } from '../components/Game';
import { BeamConfig } from 'mc-account-api-react';

export default function App() {
  return (
    <BeamConfig token="">
      <Game />
    </BeamConfig>
  );
}

Option 2: Setting the token manually

'use client';

import { Game } from '../components/Game';
import { BeamConfig } from 'mc-account-api-react';
import AsyncStorage from '@react-native-async-storage/async-storage';

export default function App() {
  const { setToken } = useBeam();
  
  async function handleSetToken() {
    const userToken = await AsyncStorage.getItem("your_token_key");
    setToken(userToken)
  }

  return (
    <button onClick={handleSetToken}>Set the token manually</button>
  );
}

Once you completed either step 1 or 2, you'll be authorized to use the provided hooks as follows.

import { useEditProfile } from 'mc-account-api-react';

export const YourComponent = () => {
  const { mutate } = useEditProfile();

  return (
    <button
      onClick={() => mutate({
        data: {
          // Add your payload here
        }
      })}
    type="button"
    >
      Chagne your profile
    </button>
  )
}


FAQs

Package last updated on 13 Sep 2023

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