mirror of
https://github.com/waku-org/js-waku.git
synced 2025-01-12 21:44:33 +00:00
Create Waku
This commit is contained in:
parent
1e64ac8f7c
commit
2ae9a6ca00
38259
examples/min-js-web-chat/package-lock.json
generated
Normal file
38259
examples/min-js-web-chat/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -6,6 +6,7 @@
|
||||
"@testing-library/jest-dom": "^5.11.4",
|
||||
"@testing-library/react": "^11.1.0",
|
||||
"@testing-library/user-event": "^12.1.10",
|
||||
"js-waku": "../../build/main",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-scripts": "4.0.3",
|
||||
|
@ -1,22 +1,29 @@
|
||||
import logo from './logo.svg';
|
||||
import './App.css';
|
||||
import { Waku } from 'js-waku';
|
||||
import * as React from 'react';
|
||||
|
||||
function App() {
|
||||
const [waku, setWaku] = React.useState(undefined);
|
||||
const [wakuStarting, setWakuStarting] = React.useState(false);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!!waku) return;
|
||||
if (wakuStarting) return;
|
||||
|
||||
setWakuStarting(true);
|
||||
|
||||
Waku.create().then((waku) => {
|
||||
setWaku(waku);
|
||||
setWakuStarting(false);
|
||||
});
|
||||
}, [waku, wakuStarting]);
|
||||
|
||||
const wakuStatus = !!waku ? 'Started' : wakuStarting ? 'Loading' : 'Error';
|
||||
|
||||
return (
|
||||
<div className="App">
|
||||
<header className="App-header">
|
||||
<img src={logo} className="App-logo" alt="logo" />
|
||||
<p>
|
||||
Edit <code>src/App.js</code> and save to reload.
|
||||
</p>
|
||||
<a
|
||||
className="App-link"
|
||||
href="https://reactjs.org"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Learn React
|
||||
</a>
|
||||
<p>{wakuStatus}</p>
|
||||
</header>
|
||||
</div>
|
||||
);
|
||||
|
27
guides/relay-receive-send-messages.md
Normal file
27
guides/relay-receive-send-messages.md
Normal file
@ -0,0 +1,27 @@
|
||||
# Received and Send messages using Waku Relay
|
||||
|
||||
Waku Relay is a gossip protocol that enables you to send and receive messages.
|
||||
You can find Waku Relay's specifications on [Vac RFC](https://rfc.vac.dev/spec/11/).
|
||||
|
||||
Before starting, you need to choose a _Content Topic_ for your dApp.
|
||||
Check out the [choose a content topic guide](choose-content-topic.md) to learn more about content topics.
|
||||
|
||||
For the purpose of this guide, we are using a unique content topic: `/relay-guide/1/chat/proto`.
|
||||
|
||||
# Installation
|
||||
|
||||
You can install [js-waku](https://npmjs.com/package/js-waku) using your favorite package manager:
|
||||
|
||||
```shell
|
||||
npm install js-waku
|
||||
```
|
||||
|
||||
# Create Waku instance
|
||||
|
||||
In order to interact with the Waku network, you first need a Waku instance:
|
||||
|
||||
```js
|
||||
import { Waku } from 'js-waku';
|
||||
|
||||
const wakuNode = await Waku.create();
|
||||
```
|
Loading…
x
Reference in New Issue
Block a user