Community코딩 & 개발github.com

rivet-dev/rivetkit-client-javascript

브라우저, Node.js, 또는 Bun 클라이언트에서 Rivet 액터에 연결하고, 클라이언트를 생성하며, 액션을 호출하거나 연결을 관리하는 RivetKit JavaScript 클라이언트 가이드입니다.

rivetkit-client-javascript란 무엇인가요?

이 스킬은 RivetKit JavaScript 클라이언트를 사용하는 방법을 설명합니다. 브라우저, Node.js, Bun 환경에서 Rivet 액터와의 연결 설정, 클라이언트 생성, 액션 호출, 연결 관리를 위한 구체적인 지침을 제공합니다. `rivetkit/client` 라이브러리를 기반으로 하여, 개발자가 Rivet 분산 액터 시스템과 효율적으로 상호작용할 수 있도록 돕습니다. 특히 연결 수명 주기 관리, 에러 처리, 비동기 작업 수행에 대한 모범 사례를 포함하고 있어, 실시간 애플리케이션이나 마이크로서비스 기반 시스템을 구축하는 개발자에게 유용합니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/rivet-dev/skills/tree/main/skills/rivetkit-client-javascript

Installed? Explore more 코딩 & 개발 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

rivetkit-client-javascript은(는) 무엇을 하나요?

RivetKit JavaScript 클라이언트 가이드입니다. 브라우저, Node.js, 또는 Bun 클라이언트에서 rivetkit/client를 사용해 Rivet 액터에 연결하고, 클라이언트를 생성하며, 액션을 호출하거나 연결을 관리하는 방법을 다룹니다.

설치

npm install @rivetkit/client

또는

yarn add @rivetkit/client

또는

bun add @rivetkit/client

기본 사용법

import { RivetClient } from '@rivetkit/client';

const client = new RivetClient({
  endpoint: 'https://my-actor.rivet.run',
  token: 'your-auth-token'
});

// 액션 호출
const result = await client.callAction('greet', { name: '세계' });
console.log(result);

클라이언트 생성

클라이언트 생성 시에는 Rivet 액터의 엔드포인트와 인증 토큰을 제공해야 합니다. 선택적으로 연결 옵션을 전달할 수 있습니다.

const client = new RivetClient({
  endpoint: 'https://my-actor.rivet.run',
  token: 'your-auth-token',
  options: {
    timeout: 5000,
    retries: 3
  }
});

액션 호출

callAction 메서드를 사용하여 액터의 액션을 호출합니다. 첫 번째 인수는 액션 이름, 두 번째 인수는 페이로드입니다.

const response = await client.callAction('processOrder', {
  orderId: '12345',
  items: ['item1', 'item2']
});

연결 관리

연결 종료

await client.disconnect();

재연결

await client.reconnect();

상태 확인

const status = client.getStatus();
console.log(status); // 'connected', 'disconnected', 'reconnecting', 'error'

에러 처리

try {
  const result = await client.callAction('riskyAction', { data: 'test' });
} catch (error) {
  if (error.code === 'TIMEOUT') {
    console.error('요청 시간이 초과되었습니다');
  } else if (error.code === 'AUTH_FAILED') {
    console.error('인증에 실패했습니다');
  } else {
    console.error('알 수 없는 오류:', error);
  }
}

환경별 참고 사항

브라우저

브라우저 환경에서는 WebSocket을 지원해야 합니다. 일부 오래된 브라우저에서는 폴리필이 필요할 수 있습니다.

Node.js

Node.js 18 이상을 권장합니다. 이전 버전에서는 WebSocket 패키지가 필요할 수 있습니다.

Bun

Bun은 WebSocket을 기본적으로 지원하므로 추가 설정이 필요하지 않습니다.

Individual skills in this repo

This repo contains 6 individual skills — each has its own dedicated page.

관련 스킬