npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cellsweb/rpc-client

v1.0.18

Published

Client SDK & React / React Native hooks for CellsWeb RPC API — universal fetch, automatic multipart form-data, and provider context

Downloads

2,656

Readme

@cellsweb/rpc-client

npm version license

Official Client SDK & React / React Native Hooks for CellsWeb RPC API. Supports universal fetch, automatic multipart FormData object conversion, base header/body merging, and React hooks.

[!NOTE] @cellsweb/rpc-client is the official client-side SDK designed specifically to consume backend RPC services powered by @cellsweb/rpc-core.


📦 Installation

npm install @cellsweb/rpc-client
# or
pnpm add @cellsweb/rpc-client
# or
yarn add @cellsweb/rpc-client

⚡ Quick Start

1. Direct API Request (rawRpcRequest)

Use rawRpcRequest anywhere outside of React providers — inside services, utility functions, state stores, or background scripts:

import { rawRpcRequest, RpcError } from "@cellsweb/rpc-client";

try {
  const data = await rawRpcRequest<{ user: UserProfile }>({
    baseUrl: "https://api.example.com",
    namespace: "auth",
    functionName: "profile",
    headers: { authorization: "Bearer custom_auth_token" },
  });
  console.log("User profile:", data.user);
} catch (err) {
  if (err instanceof RpcError) {
    console.error("RPC Error:", err.code, err.message, err.status);
  }
}

2. Standalone Client Instance (createRpcClient)

Create a configured client instance with default baseUrl, default headers, and default body payload:

import { createRpcClient } from "@cellsweb/rpc-client";

export const rpc = createRpcClient({
  baseUrl: "https://api.example.com",
  defaultHeaders: () => ({ authorization: `Bearer ${getAuthToken()}` }),
  defaultBody: { appId: "com.example.app" },
});

// Use anywhere in your app:
const result = await rpc.request<{ success: boolean }>({
  namespace: "orders",
  functionName: "create",
  data: { items: [{ id: "p1", quantity: 2 }] },
});

3. React & React Native Setup (<RpcProvider>)

Wrap your app root with <RpcProvider> to share configuration across all components:

import React from "react";
import { RpcProvider } from "@cellsweb/rpc-client/react";

export function App() {
  return (
    <RpcProvider
      baseUrl="https://api.example.com"
      defaultHeaders={() => ({ authorization: `Bearer ${getAuthToken()}` })}
      defaultBody={{ appId: "com.example.app" }}
    >
      <MainNavigator />
    </RpcProvider>
  );
}

4. Fetching Data with useRpcQuery

Data fetching hook with loading states, error handling, auto-refetch, and manual trigger:

import React from "react";
import { useRpcQuery } from "@cellsweb/rpc-client/react";

function ProductList() {
  const { data, loading, error, refetch } = useRpcQuery<{ products: Product[] }>({
    namespace: "products",
    functionName: "list",
    data: { category: "electronics" },
  });

  if (loading) return <div>Loading products…</div>;
  if (error) return <div>Error loading products!</div>;

  return (
    <div>
      <button onClick={() => refetch()}>Refresh</button>
      {data?.products.map((p) => (
        <div key={p.id}>{p.name}</div>
      ))}
    </div>
  );
}

5. Mutations & Automatic File Uploads with useRpcMutation

Mutation hook for POST requests. Supports automatic multipart FormData auto-detection for Web (File/Blob) and React Native ({ uri, name, type }) objects!

import React, { useState } from "react";
import { useRpcMutation } from "@cellsweb/rpc-client/react";

function AvatarUploader() {
  const [file, setFile] = useState<File | null>(null);

  const { mutate, loading, error } = useRpcMutation({
    namespace: "public",
    functionName: "upload",
  });

  const handleUpload = async () => {
    if (!file) return;

    // Passing file objects automatically triggers multipart/form-data conversion!
    const result = await mutate({
      title: "My Profile Avatar",
      file: file,
    });

    console.log("Upload successful:", result);
  };

  return (
    <div>
      <input type="file" onChange={(e) => setFile(e.target.files?.[0] ?? null)} />
      <button onClick={handleUpload} disabled={loading}>
        {loading ? "Uploading…" : "Upload Avatar"}
      </button>
    </div>
  );
}

🛠 Features

  • Automatic Multipart Form-Data Conversion: Pass any JavaScript object with embedded Web File/Blob or React Native { uri, name, type } objects. @cellsweb/rpc-client automatically builds FormData and posts seamlessly!
  • Header & Body Merging: Configure defaultHeaders and defaultBody globally or dynamically per request.
  • Typed Error Handling: Catches server RPC error responses and throws RpcError with code, message, status, and meta.
  • Zero Overhead: Focused exclusively on clean, high-performance RPC API dispatching.

📜 API Reference

createRpcClient(config)

  • baseUrl: Base URL of the CellsWeb server.
  • rpcEndpoint: Endpoint path (default "/rpc").
  • defaultHeaders: Additional headers object or dynamic getter function.
  • defaultBody: Default properties to merge into request payloads.
  • timeoutMs: Request timeout in milliseconds (default 30000).

rawRpcRequest(options)

  • baseUrl: Full base URL.
  • namespace: RPC namespace string.
  • functionName: RPC function name string.
  • data: Payload object.
  • headers: Additional headers object.
  • multipart: Force multipart/form-data encoding.

📄 License

MIT © Minhazur Rahman