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

@jinglescode/nostr-chat-plugin

Package Overview
Dependencies
Maintainers
0
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jinglescode/nostr-chat-plugin

A chat room React component that uses NOSTR protocol for messaging.

  • 0.0.10
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
0
Weekly downloads
 
Created
Source

Nostr Chat Provider

A chat room React component that uses NOSTR protocol for messaging.

Usage

Install the package using npm:

npm install @jinglescode/nostr-chat-plugin

In your _app.tsx file, import NostrChatProvider and wrap your component with it:

import { NostrChatProvider } from "@jinglescode/nostr-chat-plugin";

export default function App({ Component, pageProps }: AppProps) {
  return (
    <NostrChatProvider>
      <Component {...pageProps} />
    </NostrChatProvider>
  );
}

To use the chat component, import useNostrChat:

import { useNostrChat } from "@jinglescode/nostr-chat-plugin";

const { subscribeRoom, publishMessage, messages, generateNsec, setUser } =
  useNostrChat();

API

First, depending if your user has a nostr key, if not, you can generate one:

const {
  nsec: string;
  pubkey: string;
} = generateNsec();

For users that already have a nostr key, you can set it:

setUser({
  nsec: nsec,
  pubkey: pubkey,
});

Then, when user enters a page with chat, you can subscribe to a room ID:

subscribeRoom("room-id-here");

Doing so will populate and listen for new messages from the room.

When the connected user wants to send a message, they can publish a message to the room:

publishMessage("message here");

FAQs

Package last updated on 14 Oct 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