Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

partykit

БесплатноБез исполняемых скриптовНе проверен

PartyKit and its successor PartyServer are libraries for building real-time multiplayer and collaborative apps on Cloudflare Durable Objects: each room is a…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

PartyKit and PartyServer

Overview

PartyKit started as a hosted platform (*.partykit.dev, npx partykit deploy). It is now run by Cloudflare, which maintains its successor PartyServer (partyserver on npm, repo cloudflare/partykit): a Server class on top of Cloudflare Durable Objects with rooms, connection lifecycle hooks, broadcasting and hibernation, deployed with wrangler to your own Cloudflare account.

The hosted PartyKit platform is being shut down: no new projects since 9 October 2026, deploys stop on 16 October, and the platform and its room data are deleted on 23 October 2026. npx partykit deploy to your own Cloudflare account also stops working that day. New projects must use PartyServer; existing ones should migrate (see below). The partykit CLI package was last published in May 2025.

Related packages: partysocket (client, with reconnect and buffering), y-partyserver (Yjs collaborative editing), hono-party (Hono middleware), partywhen (scheduled tasks).

Instructions

  1. Create a Worker project and install:
npm create cloudflare@latest chat-rooms
cd chat-rooms
npm install partyserver partysocket
  1. Write the server. One class per kind of room; the room name comes from the URL.
// src/server.ts
import { routePartykitRequest, Server } from "partyserver";
import type { Connection, ConnectionContext } from "partyserver";

type Env = { ChatRoom: DurableObjectNamespace<ChatRoom> };

export class ChatRoom extends Server<Env> {
  static options = { hibernate: true };

  async onStart() {
    // runs on first start and after waking from hibernation
    this.messages = (await this.ctx.storage.get<string[]>("messages")) ?? [];
  }
  messages: string[] = [];

  onConnect(conn: Connection, _ctx: ConnectionContext) {
    conn.send(JSON.stringify({ type: "history", messages: this.messages }));
  }

  async onMessage(sender: Connection, message: string) {
    this.messages = [...this.messages.slice(-99), message];
    await this.ctx.storage.put("messages", this.messages);
    this.broadcast(JSON.stringify({ type: "message", text: message }), [sender.id]);
  }
}

export default {
  async fetch(request: Request, env: Env): Promise<Response> {
    return (await routePartykitRequest(request, env)) || new Response("Not Found", { status: 404 });
  },
} satisfies ExportedHandler<Env>;

Note the argument order: onMessage(connection, message) (PartyKit's old API had message, sender). Use this.name for the room name, this.ctx.storage for storage, this.env for bindings.

  1. Configure wrangler.jsonc. Unlike PartyKit, wrangler does not create Durable Object bindings or migrations for you; add a new migration entry whenever you add, rename or remove a class.
{
  "name": "chat-rooms",
  "main": "src/server.ts",
  "compatibility_date": "2025-06-01",
  "compatibility_flags": ["nodejs_compat"],
  "durable_objects": { "bindings": [{ "name": "ChatRoom", "class_name": "ChatRoom" }] },
  "migrations": [{ "tag": "v1", "new_sqlite_classes": ["ChatRoom"] }]
}

routePartykitRequest serves /parties/:server/:room, where :server is the kebab-cased binding name (ChatRoom becomes chat-room). Binding named Main is the default party for older clients.

  1. Connect from the browser or React:
import usePartySocket from "partysocket/react";

const socket = usePartySocket({
  host: import.meta.env.VITE_PARTY_HOST, // e.g. chat-rooms.northwind.workers.dev, or localhost:8787 in dev
  party: "chat-room",
  room: "support-team",
  onMessage(event) {
    const data = JSON.parse(event.data);
    if (data.type === "history") setMessages(data.messages);
    else setMessages((prev) => [...prev, data.text]);
  },
});
socket.send("Deploy finished");
  1. Run and deploy: npx wrangler dev (default http://localhost:8787), npx wrangler login, npx wrangler deploy. Secrets: npx wrangler secret put OPENAI_API_KEY; plain settings go in vars.
  2. Gate connections in the Worker, not in the room: pass onBeforeConnect(request, { party, name }) to routePartykitRequest and return a Response (401 or 403) to refuse, or nothing to allow.
  3. Other hooks: onClose, onError, onRequest (HTTP to the room), onAlarm (set with this.ctx.storage.setAlarm), getConnectionTags, this.getConnections(tag). Per-connection state up to 2 KB: conn.setState(...).

Examples

Live cursors in a shared canvas

export class CursorRoom extends Server {
  static options = { hibernate: true };

  onMessage(sender: Connection, message: string) {
    // clients send {"x":412,"y":96,"name":"Priya"} on pointer move
    this.broadcast(JSON.stringify({ id: sender.id, ...JSON.parse(message) }), [sender.id]);
  }

  onClose(conn: Connection) {
    this.broadcast(JSON.stringify({ id: conn.id, gone: true }));
  }
}

Result: each browser tab sees the other tabs' cursors move in real time and vanish when a tab closes. Cursor positions a

Полный SKILL.md на GitHub

Установить partykit в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл partykit?

PartyKit and its successor PartyServer are libraries for building real-time multiplayer and collaborative apps on Cloudflare Durable Objects: each room is a server instance that handles WebSocket connections, broadcasts and storage. Use this skill when a user asks for live cursors, chat rooms, collaborative editing, real-time polls or any WebSocket sync, or needs to migrate off the hosted PartyKit platform, which shuts down on 23 October 2026.

Как установить скилл partykit?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл partykit запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить partykit с