New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@y-sweet/sdk

Package Overview
Dependencies
Maintainers
2
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@y-sweet/sdk

Javascript/Typescript backend SDK for building collaboration features with y-sweet.

latest
Source
npmnpm
Version
0.9.1
Version published
Maintainers
2
Created
Source

@y-sweet/sdk

GitHub Repo stars Chat on Discord npm

JavaScript/TypeScript backend SDK for building collaboration features with y-sweet.

Installation

npm install @y-sweet/sdk

Documentation

Read the documentation for guides and API references.

Examples

Explore our collaborative examples to help you get started.

All examples are open source and live in this repository, within /examples.

Using @y-sweet/sdk

Here’s how access control works in y-sweet:

  • Your server (i.e. your Next.js server component) connects to y-sweet using an API key and asks for a client token for a specific document.
  • Your server then passes that client token to the client, often as props to a client-side React component.
  • Your client then connects to y-sweet using the client token.

The client token contains all the information needed for the client to connect to a y-sweet document, so the client doesn’t need any configuration. But you do need to tell your server how to talk to y-sweet, by passing a server token.

A server token combines a URL and a secret key. It can be represented either as a JSON object with url and token as keys, or as a JSONified string of the same. This makes it easy to store the server token in a secret store, and pass it to your server code as an environment variable.

import { YDocProvider } from '@y-sweet/react'
import { getOrCreateDocAndToken } from '@y-sweet/sdk'

type HomeProps = {
  searchParams: Record<string, string>
}

export default async function Home({ searchParams }: HomeProps) {
    // Point to a local or production y-sweet server.
    const connectionString = "ys://localhost:8080"

    const clientToken = await getOrCreateDocAndToken(connectionString, searchParams.doc)

    return (
        <YDocProvider clientToken={clientToken} setQueryParam="doc">
            // Call your collaborative interface here
        </YDocProvider>
    )
}

FAQs

Package last updated on 16 Sep 2025

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