A React component library for rendering common AT Protocol records for applications such as Bluesky and Leaflet.

add documentation that atcute records can be passed directly to components

Changed files
+81 -2
src
+35
README.md
···
<LeafletDocument did={did} rkey={rkey} record={documentRecord} />
```
+
### Using atcute Directly
+
+
Use atcute directly to construct records and pass them to components—fully compatible!
+
+
```tsx
+
import { Client, simpleFetchHandler, ok } from '@atcute/client';
+
import type { AppBskyFeedPost } from '@atcute/bluesky';
+
import { BlueskyPost } from 'atproto-ui';
+
+
// Create atcute client
+
const client = new Client({
+
handler: simpleFetchHandler({ service: 'https://public.api.bsky.app' })
+
});
+
+
// Fetch a record
+
const data = await ok(
+
client.get('com.atproto.repo.getRecord', {
+
params: {
+
repo: 'did:plc:ttdrpj45ibqunmfhdsb4zdwq',
+
collection: 'app.bsky.feed.post',
+
rkey: '3m45rq4sjes2h'
+
}
+
})
+
);
+
+
const record = data.value as AppBskyFeedPost.Main;
+
+
// Pass atcute record directly to component!
+
<BlueskyPost
+
did="did:plc:ttdrpj45ibqunmfhdsb4zdwq"
+
rkey="3m45rq4sjes2h"
+
record={record}
+
/>
+
```
+
## API Reference
### Components
+44 -1
src/App.tsx
···
import React, { useState, useCallback, useRef } from "react";
import { AtProtoProvider } from "../lib";
-
import "../lib/styles.css"
+
import "../lib/styles.css";
import "./App.css";
import { TangledString } from "../lib/components/TangledString";
···
// Pass prefetched record—BlueskyPost won't re-fetch it
return <BlueskyPost did={did} rkey={rkey} record={record} />;
};`;
+
+
const atcuteUsageSnippet = `import { Client, simpleFetchHandler, ok } from '@atcute/client';
+
import type { AppBskyFeedPost } from '@atcute/bluesky';
+
import { BlueskyPost } from 'atproto-ui';
+
+
// Create atcute client
+
const client = new Client({
+
handler: simpleFetchHandler({ service: 'https://public.api.bsky.app' })
+
});
+
+
// Fetch a record
+
const data = await ok(
+
client.get('com.atproto.repo.getRecord', {
+
params: {
+
repo: 'did:plc:ttdrpj45ibqunmfhdsb4zdwq',
+
collection: 'app.bsky.feed.post',
+
rkey: '3m45rq4sjes2h'
+
}
+
})
+
);
+
+
const record = data.value as AppBskyFeedPost.Main;
+
+
// Pass atcute record directly to component!
+
<BlueskyPost
+
did="did:plc:ttdrpj45ibqunmfhdsb4zdwq"
+
rkey="3m45rq4sjes2h"
+
record={record}
+
/>`;
const codeBlockBase: React.CSSProperties = {
fontFamily: 'Menlo, Consolas, "SFMono-Regular", ui-monospace, monospace',
···
style={codeTextStyle}
>
{prefetchedDataSnippet}
+
</code>
+
</pre>
+
<p
+
style={{
+
color: `var(--demo-text-secondary)`,
+
margin: "16px 0 8px",
+
}}
+
>
+
Use atcute directly to construct records and pass them to
+
components—fully compatible!
+
</p>
+
<pre style={codeBlockStyle}>
+
<code className="language-tsx" style={codeTextStyle}>
+
{atcuteUsageSnippet}
</code>
</pre>
</section>
+2 -1
tsconfig.lib.json
···
"declarationDir": "dist-lib",
"sourceMap": true,
"outDir": "./lib-dist",
-
"rootDir": "./lib"
+
"rootDir": "./lib",
+
"types": ["@atcute/bluesky"]
},
"include": ["lib/**/*.ts", "lib/**/*.tsx"]
}