YDocProvider is a provider that runs on the client (i.e. in the user’s browser). It connects to a y-sweet server based on information passed down to it via clientToken, which contains both the URL of the server and a token for connecting to it.

YDocProvider makes the Y.Doc instance available to its children via React context, either directly through useYDoc, or indirectly through hooks like useMap and useArray.

setQueryParam is an optional parameter that tells the provider to put the document ID in the URL as the "doc" parameter. The specific name "doc" is not special to y-sweet, but it should refer to the same parameter pulled from searchParams.

  • you don't need set query param if you don't want to get the doc id from the url
y-sweet was created by Jamsocket.