🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@hocuspocus/provider

Package Overview
Dependencies
Maintainers
6
Versions
161
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hocuspocus/provider - npm Package Compare versions

Comparing version
4.0.0-rc.7
to
4.0.0
+1
-1
dist/hocuspocus-provider.cjs

@@ -541,3 +541,3 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

//#region packages/provider/src/version.ts
const version = "4.0.0-rc.7";
const version = "4.0.0";

@@ -544,0 +544,0 @@ //#endregion

@@ -511,3 +511,3 @@ import { WsReadyStates, awarenessStatesToArray, makeRoutingKey, parseRoutingKey, readAuthMessage, writeAuthentication } from "@hocuspocus/common";

//#region packages/provider/src/version.ts
const version = "4.0.0-rc.7";
const version = "4.0.0";

@@ -514,0 +514,0 @@ //#endregion

{
"name": "@hocuspocus/provider",
"version": "4.0.0-rc.7",
"version": "4.0.0",
"description": "hocuspocus provider",

@@ -32,3 +32,3 @@ "homepage": "https://hocuspocus.dev",

"dependencies": {
"@hocuspocus/common": "^4.0.0-rc.7",
"@hocuspocus/common": "^4.0.0",
"@lifeomic/attempt": "^3.0.2",

@@ -42,3 +42,3 @@ "lib0": "^0.2.87",

},
"gitHead": "d214278ee34bd1d776054cdc2a2227e3f05449d7",
"gitHead": "1c1b34800f702a06e1ce236e8a175c82876bff42",
"repository": {

@@ -45,0 +45,0 @@ "url": "https://github.com/ueberdosis/hocuspocus"

@@ -7,9 +7,66 @@ # @hocuspocus/provider

## Introduction
The client-side provider for [Hocuspocus](https://github.com/ueberdosis/hocuspocus). It connects to a Hocuspocus server over WebSockets and syncs one or more [Y.js](https://github.com/yjs/yjs) documents, including awareness (presence), authentication, and stateless messaging.
The client-side provider for [Hocuspocus](https://github.com/ueberdosis/hocuspocus). Connects to a Hocuspocus server over WebSockets and syncs one or more [Y.js](https://github.com/yjs/yjs) documents — including awareness (presence), authentication, and stateless messaging.
## Official Documentation
Documentation can be found in the [GitHub repository](https://github.com/ueberdosis/hocuspocus).
> **Building a React app?** Use [`@hocuspocus/provider-react`](../provider-react) instead — it wraps the provider in components and hooks so React handles the lifecycle for you (including StrictMode double-mounts).
## Installation
```bash
npm install @hocuspocus/provider yjs
```
## Usage
```js
import * as Y from "yjs"
import { HocuspocusProvider } from "@hocuspocus/provider"
const ydoc = new Y.Doc()
const provider = new HocuspocusProvider({
url: "ws://127.0.0.1:1234",
name: "example-document",
document: ydoc,
})
```
Changes to `ydoc` are now synced to every other client connected to the same `name`.
### Authenticating
Pass a `token` — it's forwarded to the server's `onAuthenticate` hook:
```js
new HocuspocusProvider({
url: "wss://collab.example.com",
name: "example-document",
document: ydoc,
token: "super-secret-token",
})
```
### Sharing a socket across documents
Create a `HocuspocusProviderWebsocket` once, then reuse it for multiple documents:
```js
import {
HocuspocusProvider,
HocuspocusProviderWebsocket,
} from "@hocuspocus/provider"
const socket = new HocuspocusProviderWebsocket({ url: "ws://127.0.0.1:1234" })
const doc1 = new HocuspocusProvider({ websocketProvider: socket, name: "doc-1" })
const doc2 = new HocuspocusProvider({ websocketProvider: socket, name: "doc-2" })
```
Call `provider.destroy()` to disconnect a single document. Call `socket.destroy()` to tear down the shared connection.
## Documentation
Full configuration, events, and awareness reference: [tiptap.dev/docs/hocuspocus/provider](https://tiptap.dev/docs/hocuspocus/provider/overview).
## License
Hocuspocus is open-sourced software licensed under the [MIT license](https://github.com/ueberdosis/hocuspocus/blob/main/LICENSE.md).
MIT — see [LICENSE.md](https://github.com/ueberdosis/hocuspocus/blob/main/LICENSE.md).