Signed in as {user.profile?.handle ?? user.did}
{:else} {/if} ``` `@foxui/core` also exports `Avatar`, `Input`, and other UI primitives you can use. ### `src/routes/user/+page.svelte` (basic only) Only if the user chose `basic`. Create this file: ```svelteSigned in as {user.profile?.handle ?? user.did}
{:else}Signed in as {user.did}
{:else} {/if} ``` ### Write operations ```ts import { putRecord, deleteRecord, uploadBlob, createTID } from '$lib/atproto'; await putRecord({ collection: 'your.collection.name', rkey: createTID(), record: { text: 'hello', createdAt: new Date().toISOString() } }); await deleteRecord({ collection: 'your.collection.name', rkey: 'some-key' }); const blob = await uploadBlob({ blob: file }); // For images, returns: { $type: 'blob', ref: { $link: string }, mimeType: string, size: number, aspectRatio: { width, height } } // aspectRatio is auto-detected for image/* blobs, or you can pass it explicitly: // await uploadBlob({ blob: file, aspectRatio: { width: 2000, height: 1144 } }) // Store the blob reference in a record await putRecord({ collection: 'your.collection.name', rkey: createTID(), record: { image: blob, createdAt: new Date().toISOString() } }); ``` ### Displaying blobs ```ts import { getBlobURL, getCDNImageBlobUrl } from '$lib/atproto'; // Option 1: Direct PDS URL (works for any blob type) const url = await getBlobURL({ did: 'did:plc:...', blob: record.image }); // Option 2: Bluesky CDN URL (faster, cached, image-only, returns WebP thumbnails) const cdnUrl = getCDNImageBlobUrl({ did: 'did:plc:...', blob: record.image }); ``` ### Image compression helper The `image-helper.ts` module provides utilities for working with image blobs: ```ts import { compressImage, checkAndUploadImage, getImageFromRecord } from '$lib/atproto/image-helper'; // Compress an image before uploading (default: max 900KB, max 2048px dimension, outputs WebP) const { blob: compressedBlob, aspectRatio } = await compressImage(file); const uploaded = await uploadBlob({ blob: compressedBlob }); // Or use checkAndUploadImage to handle compression + upload in one step // Works with File objects, string URLs (with an image proxy), or already-uploaded blob refs const record = { image: someFileOrUrl }; await checkAndUploadImage(record, 'image', '/api/image-proxy?url='); // Get a display URL from a record's blob field (handles blob refs, object URLs, and strings) const displayUrl = getImageFromRecord(record, did, 'image'); ``` ### Read operations (no auth needed) ```ts import { listRecords, getRecord, getDetailedProfile } from '$lib/atproto'; const records = await listRecords({ did: 'did:plc:...', collection: 'your.collection.name' }); const profile = await getDetailedProfile({ did: 'did:plc:...' }); ```