Skip to content

reactive/data-client / .agents/skills/data-client-setup

data-client-setup

Verified

Install and set up @data-client/react or @data-client/vue in a project. Detects project type (NextJS, Expo, React Native, Vue, plain React) and protocol (REST, GraphQL, custom), then follows the bundled protocol-specific setup guide.

FileKindSize
SKILL.mdskill md13.9 KB
evals/evals.jsonconfig12.6 KB
references.jsonconfig523 B
references/DataClientPlugin.mdmarkdown6.6 KB
references/DataProvider.mdmarkdown6.6 KB
references/data-client-endpoint-setup.mdmarkdown8.5 KB
references/data-client-endpoint-setup/references/Endpoint.mdmarkdown20.9 KB
references/data-client-endpoint-setup/references/Endpoint.vue.mdmarkdown20.5 KB
references/data-client-graphql-setup.mdmarkdown4.8 KB
references/data-client-graphql-setup/references/auth.mdmarkdown1.9 KB
references/data-client-rest-setup.mdmarkdown7.6 KB
references/data-client-rest-setup/references/RestEndpoint.mdmarkdown45.2 KB
references/data-client-rest-setup/references/RestEndpoint.vue.mdmarkdown46.1 KB
references/data-client-rest-setup/references/auth.mdmarkdown9.4 KB
references/data-client-rest-setup/references/auth.vue.mdmarkdown9.7 KB
references/data-client-rest-setup/references/axios-migration.mdmarkdown25.4 KB
references/data-client-rest-setup/references/axios-migration.vue.mdmarkdown25.5 KB
references/data-client-rest-setup/references/django.mdmarkdown2.3 KB
references/data-client-rest-setup/references/fetch-migration.mdmarkdown4.0 KB
references/data-client-rest-setup/references/got-migration.mdmarkdown4.5 KB
references/data-client-rest-setup/references/hookifyResource.mdmarkdown6.0 KB
references/data-client-rest-setup/references/hookifyResource.vue.mdmarkdown6.3 KB
references/data-client-rest-setup/references/ky-migration.mdmarkdown3.9 KB
references/data-client-rest-setup/references/resource.mdmarkdown27.0 KB
references/data-client-rest-setup/references/resource.vue.mdmarkdown27.1 KB
references/data-client-rest-setup/references/superagent-migration.mdmarkdown4.1 KB
references/getDefaultManagers.mdmarkdown6.1 KB
references/getDefaultManagers.vue.mdmarkdown3.8 KB
references/installation.mdmarkdown4.0 KB
references/installation.vue.mdmarkdown2.7 KB
references/tanstack-query-migration.mdmarkdown31.1 KB

references/data-client-rest-setup/references/ky-migration.md

View on GitHub
<!-- Generated by `yarn build:skills` from .agents/skills/data-client-rest-setup/references/ky-migration.md. Edit the source, not this file. -->

# Ky → @data-client/rest Migration

## Detection

- `"ky"` in `package.json` dependencies
- `import ky from 'ky'` or `import ky from 'ky/umd'` in source

Search patterns:
- `import.*from ['"]ky['"]` — import statements
- `ky\.create` — instance creation
- `ky\.(get|post|put|patch|delete|head)` — direct calls

## Migration Rules

### Basic instance → base class

```ts
// Before: ky instance
import ky from 'ky';
const api = ky.create({
  prefixUrl: 'https://api.example.com',
  headers: { Authorization: `Bearer ${token}` },
  hooks: {
    beforeRequest: [req => { /* ... */ }],
    afterResponse: [(_req, _opts, res) => { /* ... */ }],
  },
});
const users = await api.get('users').json<User[]>();

// After: RestEndpoint base class
import { RestEndpoint, RestGenerics } from '@data-client/rest';

class ApiEndpoint<O extends RestGenerics = any> extends RestEndpoint<O> {
  urlPrefix = 'https://api.example.com';

  getHeaders(headers: HeadersInit) {
    return {
      ...headers,
      Authorization: `Bearer ${token}`,
    };
  }
}

export const getUsers = new ApiEndpoint({
  path: '/users',
  schema: [User],
});
```

### Key conversions

| Ky pattern | RestEndpoint equivalent |
|------------|----------------------|
| `prefixUrl` | `urlPrefix` |
| `headers` option | `getHeaders()` |
| `hooks.beforeRequest` | `getHeaders()` or `getRequestInit()` |
| `hooks.afterResponse` | `process()` in the base class |
| `hooks.beforeError` | `fetchResponse()` override |
| `ky.create()` shared options | Base class overrides |
| `.json<T>()` | Automatic — RestEndpoint parses JSON by default |
| `HTTPError` | `NetworkError` |
| `searchParams` option | `searchParams` type on endpoint |
| `timeout` | `AbortSignal.timeout(ms)` in a `getRequestInit()` override, so each request gets its own timer ([Timeout](axios-migration.md#timeout)); a `signal` option would start one timer when the endpoint is created |
| `retry` (ky retries by default) | Delete it: Data Client has no retry loop, and a failed request is fetched again when a component next needs it after `errorExpiryLength` (default 1 second). Tell the user that automatic retries are dropped |
| `credentials` | `getRequestInit()` override |

### Hooks → lifecycle methods

```ts
// Before: ky hooks
const api = ky.create({
  hooks: {
    beforeRequest: [
      request => {
        request.headers.set('X-Request-Id', generateId());
      },
    ],
    afterResponse: [
      (_request, _options, response) => {
        logResponse(response.status);
        return response;
      },
    ],
    beforeError: [
      error => {
        reportError(error);
        return error;
      },
    ],
  },
});

// After: lifecycle methods
class ApiEndpoint<O extends RestGenerics = any> extends RestEndpoint<O> {
  getHeaders(headers: HeadersInit) {
    return {
      ...headers,
      'X-Request-Id': generateId(),
    };
  }

  async parseResponse(response: Response) {
    logResponse(response.status);
    return super.parseResponse(response);
  }

  async fetchResponse(input: RequestInfo, init: RequestInit) {
    try {
      return await super.fetchResponse(input, init);
    } catch (error) {
      reportError(error);
      throw error;
    }
  }
}
```

### Error handling

```ts
// Before
import { HTTPError } from 'ky';
try { ... } catch (err) {
  if (err instanceof HTTPError) {
    const body = await err.response.json();
    console.log(err.response.status, body);
  }
}

// After
import { NetworkError } from '@data-client/rest';
try { ... } catch (err) {
  if (err instanceof NetworkError) {
    console.log(err.status);
    const body = await err.response.json();
  }
}
```

## Reference

- [RestEndpoint API](https://dataclient.io/rest/api/RestEndpoint) — lifecycle methods reference
- [NetworkError](https://dataclient.io/rest/api/RestEndpoint#fetchResponse) — error class
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 197kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall