npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@onbeam/sdk

v1.0.7

Published

Beam Web SDK

Downloads

604

Readme


Beam Web SDK

The Beam Web SDK is a Typescript library that allows you to easily integrate Beam into your website, application or web-based game. It provides a simple API to authenticate your users on Beam, manage sessions and sign transactions, and access the Beam Player API.

Table of Contents

Getting Started

Before you start, make sure you obtain an API key by requesting it through build@onbeam. More information can be found on the Beam API Docs.

Installation

To get started with the SDK, install it in your project using your favorite package manager:

# with npm
npm install -S @onbeam/sdk

# or with yarn
yarn add @onbeam/sdk

# or with pnpm
pnpm add @onbeam/sdk

Creating a client

Start by creating a new instance of the Beam client, and configuring it with your API key:

import { BeamConfiguration } from '@onbeam/sdk';

const config = new BeamConfiguration({
  environment: 'mainnet',
  publishableKey: 'your-publishable-key',
  debug: true, // Logs debug information to the console
});

const client = new BeamClient(config);

Make sure your API key matches the environment you are working on. For example, if you are working on a development environment, use the development API key.

Authenticating a user

If you're using wagmi, you can authenticate a user by providing the wagmi config with our Beam Connector:

import { createConfig, http } from 'wagmi'
import { beam } from 'viem/chains';
import { beam as beamConnector } from '@onbeam/wagmi';
import { BeamConfiguration } from '@onbeam/sdk';

const beamConfig = new BeamConfiguration({ ... }) // your config from the previous step

const config = createConfig({
  chains: [beam]
  connectors: [
    beamConnector({ 
      config: beamConfig
    })
  ],
  transports: {
    [beam.id]: http(),
  },
});

Our connector supports wagmi 2.x and above, and is shipped as a separate package.

Examples

The repository includes two example apps that demonstrate how to use the Beam Web SDK:

SDK Example

The SDK example app demonstrates how to create and manage sessions for your players and is mainly suited for game developers that wish to integrate Beam into their games.

Wagmi Example

The Wagmi example app demonstrates how a 'Connect with Beam' wallet integration can be implemented in a web application. It is mainly suited for NFT marketplaces or web applications that require users to authenticate with a wallet and interact with the Beam chain.

Documentation

For more information and API references, check out our online documentation.