# use-y-js

> A custom hook simplify to create a CRDT document.

Latest version **1.1.4** (published 2023-08-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install use-y-js
pnpm add use-y-js
yarn add use-y-js
bun add use-y-js
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.4 |
| Published | 2023-08-12 |
| First published | 2023-08-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 17.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | VoNgocTrong - Rio |
| Maintainers | ngoctrong102 |
| Keywords | react, hooks, react-hooks |

## Links

- npm: https://www.npmjs.com/package/use-y-js
- Repository: https://github.com/Ngoctrong102/useYjs
- Homepage: https://github.com/Ngoctrong102/useYjs#readme
- Issues: https://github.com/Ngoctrong102/useYjs/issues
- npm.io page: https://npm.io/package/use-y-js

## Dependencies (7)

- [yjs](https://npm.io/package/yjs.md) ^13.6.7
- [nodemon](https://npm.io/package/nodemon.md) ^2.0.12
- [@babel/cli](https://npm.io/package/@babel/cli.md) ^7.14.8
- [@babel/core](https://npm.io/package/@babel/core.md) ^7.15.0
- [y-websocket](https://npm.io/package/y-websocket.md) ^1.5.0
- [@babel/preset-env](https://npm.io/package/@babel/preset-env.md) ^7.15.0
- [@babel/preset-react](https://npm.io/package/@babel/preset-react.md) ^7.14.5

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.1.4 (latest) — 2023-08-12
- 1.1.1-alpha-8 — 2023-08-12
- 1.1.1-alpha-7 — 2023-08-12
- 1.1.1-alpha-6 — 2023-08-12
- 1.1.1-alpha-5 — 2023-08-12
- 1.1.1-alpha-4 — 2023-08-12
- 1.1.1-alpha-3 — 2023-08-12
- 1.1.1-alpha-2 — 2023-08-12
- 1.1.1-alpha-1 — 2023-08-12
- 1.1.3 — 2023-08-11
- 1.1.2 — 2023-08-09
- 1.1.1 — 2023-08-09
- 1.1.0 — 2023-08-09

## README

# useYjs
A custom hook simplifies to create of a CRDT document.

## Manual
1.Start a signaling y-websocket server
```
PORT=4444 npx y-websocket
```

*Read more: [y-websocket](https://github.com/yjs/y-websocket)*

2.Intall use-y-js
```
npm install use-y-js
```

3.Import hook and start coding

```js
import { useYjs } from "use-y-js";
// ...
const { data, updateData, userInfoMap, updateFieldLocalUserInfo } = useYjs({
  signaling: "ws://localhost:4444",
  roomName: "your-room-name",
  // use for auth
  params: {
    token: "anthing"
  }
  // POJO
  initData: {
    title: "Doc title",
    content: "Doc content"
  },
  // POJO
  initUserInfo: {
    name: "Rio",
    color: "#166f9c",
    pointerLocation:  {
      x: 100,
      y: 200
    }
  },
  // Minimum time until the next userInfo data sync, defaultValue = 250
  intervalSyncTime: 300
});
```

## Demo
![Example](example.gif)

---
_Source: https://npm.io/package/use-y-js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
