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

react-outpost

v0.1.0-alpha.1

Published

⚛️ 📨 The React client SDK for Outpost. (Android/iOS/Web/Expo)

Downloads

4

Readme

react-outpost

⚛️ 📨 Outpost is a utility to help serve decentralized media using Arweave to audiences who are in possession of a particular cryptocurrency. This React SDK helps you to easily integrate and distribute content via Outpost to social token holders in your own applications.

Find out more about the motivation behind Outpost here.

Supports Android, iOS, Web and Expo. ✨

If you'd like more information about Outpost, or to host your own community, please drop into the Outpost Discord!

🚀 Getting Started

Using Yarn:

yarn add react-outpost

Using npm:

npm i -s react-outpost

✏️ Tutorial

To interface with Outpost, you must declare an <OutpostProvider/> at the root of your application, which expects a single function prop, onRequestSignMessage, which is used to safely validate the user's social token ownership. In this callback, you can use a variety of ways to sign a message, for example Ethers or WalletConnect.

import React, { useCallback, useState } from 'react';
import Outpost from 'react-outpost';

import signPersonalMessage from "...";

export default function App(): JSX.Element {
  const onRequestSignMessage = useCallback(async (address: string, signInToken: string) => {
    return signPersonalMessage([
      signInToken,
      address,
    ]);
  }, []);
  return (
    <Outpost onRequestSignMessage={onRequestSignMessage}>
      {/* TODO: awesome decentralized app */}
    </Outpost>
  );
}

Once you're done, it's simple to interact with Outpost using the exposed hooks. For example, you can list all Outpost communities:

import { useAllCommunities } from 'react-outpost';

const { loading, error, communities } = useAllCommunities();

Or authenticate with Outpost to access secure content:

import { useOutpost } from 'react-outpost';

const { requestAuthToken } = useOutpost();
const authToken = await requestAuthToken(`0xdeadbeef`);

And you can even upload an image using the useOutpost hook, which internally wraps the Outpost SDK:

import { useOutpost } from 'react-outpost';

const { uploadImage } = useOutpost();
await uploadImage({
  authToken,
  base64: `data:image/png;base64,aGVsbG8sd29ybGQ...`,
});

You can check out the complete example application using WalletConnect as a message signer in React Native here.

🦄 API

OutpostProvider

A React Context Provider used to define the signing mechanism for Outpost Auth Challenges.

Prop Types

| Name | Type | Default | Description | |--------------------|---------------------------------------|----------------------------------------|-----------------------------------------------------------------------| | baseUrl | string | https://outpost-api-v2.herokuapp.com | URL of the Outpost Server. | | requestAuthToken | (string address) => Promise<string> | Promise.reject() | Provides the ability to sign a message for a given Ethereum address |

useOutpost

A utility hook used to return the complete Outpost Client API to a React Component nested within the OutpostProvider.

type createClientResult = {
  readonly getAllCommunities: () => Promise<readonly Community[]>;
  readonly getPosts: (params: getPostsParams) => Promise<getPostsResult>;
  readonly getChallenge: (
    params: getChallengeParams
  ) => Promise<getChallengeResult>;
  readonly getAuthToken: (
    params: getAuthTokenParams
  ) => Promise<getAuthTokenResult>;
  readonly getPostPreview: (
    params: getPostPreviewParams
  ) => Promise<getPostPreviewResult>;
  readonly uploadImage: (
    params: uploadImageParams
  ) => Promise<uploadImageResult>;
  readonly uploadPost: (params: uploadPostParams) => Promise<uploadPostResult>;
  readonly uploadComment: (
    params: uploadCommentParams
  ) => Promise<uploadCommentResult>;
  readonly getPost: (params: getPostParams) => Promise<getPostResult>;
};
type OutpostContextValue = createClientResult & {
  readonly baseURL: string;
  readonly requestAuthToken: (address: string) => Promise<string>;
};
readonly useOutpost(): OutpostContextValue;

useAllCommunities

Returns a list of all currently registered Communitys on Outpost.

readonly useAllCommunities: () => useAllCommunitiesResult;
export type useAllCommunitiesResult = {
  readonly loading: boolean;
  readonly communities: readonly Community[];
  readonly error: null | Error;
};

usePosts

Returns a list of all Posts for a Community.

readonly getPosts: (params: usePostsParams) => usePostsResult;
export type usePostsParams = {
  readonly slug: string;
};
export type usePostsResult = {
  readonly posts: readonly Post[];
  readonly loading: boolean;
  readonly error: null | Error;
};

useTxIdToUri

A helper utility that converts an Arweave Transaction Id (txId) to a navigable URL, based upon the provided gateway.

readonly useTxIdToUri: () => useTxIdToUriResult;
export type useTxIdToUriResult = {
  readonly txIdToUri: (gateway: string, txId: string) => string;
};

✌️ License

MIT