Skip to main content
tinykit provides three special imports for handling data in your apps:
ImportPurpose
$dataDatabase collections with realtime updates
$contentEditable CMS text fields
$tinykitProxy for fetching external APIs

Database ($data)

Store and retrieve data with realtime subscriptions. Data is stored in Pocketbase and syncs automatically across all connected clients.

Basic Usage

CRUD Operations

All operations trigger realtime updates—any subscribed component will update automatically.

Complete Example

Creating Collections

The AI creates collections when you ask for data storage. You can also create them in the Data tab or ask the AI directly:

Content Fields ($content)

Editable text values that non-developers can change without touching code. Perfect for headlines, descriptions, and labels.

Basic Usage

Content field names are automatically converted to snake_case:
  • “Hero Title” → content.hero_title
  • “CTA Button Text” → content.cta_button_text

Default Values

Always provide fallbacks for robustness:

Field Types

TypeDescriptionExample Value
textSingle line text"Welcome to My App"
textareaMulti-line text"A longer description..."
numberNumeric value42
booleanTrue/false toggletrue
imageImage upload"/path/to/image.png"
markdownRich text (rendered as HTML)"# Heading\n\nParagraph"

Creating Content Fields

The AI creates content fields when it builds your app. You can also:
  1. Ask the AI: “Add a content field for the footer copyright text”
  2. Use the Content tab: Add fields directly in the builder
  3. Edit values: Change text in the Content tab without touching code

External APIs ($tinykit)

Fetch data from external APIs without CORS issues. The proxy routes requests through your server.

Fetching JSON

Fetching Text (RSS, HTML, XML)

Media URLs

For audio, images, and other media that need a direct URL:

Raw Fetch

For full control over the request:

When to Use Proxy

Use the proxy when fetching from external domains that would block direct browser requests:

Use Proxy

  • RSS feeds
  • External APIs without CORS headers
  • Scraping web pages
  • Remote media files (audio/video)

Don't Need Proxy

  • Your own $data collections
  • APIs with proper CORS headers
  • CDN resources (images, scripts)
  • Same-origin requests

Common Patterns

Loading States

Always show loading indicators:

Filtering and Sorting

Use $derived.by() for computed lists:
Common mistake: $derived(todos.filter(...)) won’t work. Use $derived.by(() => todos.filter(...)) for callbacks.

Combining Data and Content

Error Handling


Design Fields (CSS Variables)

While not an import, design fields work similarly—the AI creates CSS variables that you reference in your styles:
Always include fallback values: var(--name, fallback). This ensures your app works even if a design field hasn’t been created yet.
Design fields appear in the Design tab where you can adjust colors, fonts, spacing, and more with visual editors.