with one click
with one click
[HINT] Download the complete skill directory including SKILL.md and all related files
| name | fragno-author |
| description | > Use when this capability is needed. |
Note: All file paths referenced in this document are relative to this SKILL.md file.
Create or extend a Fragno fragment package with typed routes and client hooks for multiple frameworks.
Important: Before implementing anything, always curl the full docs page for the topic you're
working on (see the "Full docs" commands below). The local guidance here is intentionally concise
and assumes you have read the full docs first.
Also important: Rules of Fragno are required reading for any database-backed fragment work. They
capture the transaction/handler, hook, and ID conventions that should guide your design. See
references/rules-of-fragno.md and the full docs link below.
pnpm create fragno@latest --non-interactive --name my-fragment
This uses sensible defaults: tsdown build tool, database layer included, no agent docs, path set to
<name>.
@fragno-dev/core manually. See "assets" below.Define fragment + config in a definition module
defineFragment<TConfig>("fragment-name").build()Optional dependencies / services
withDependencies(({ config }) => ({ ... })) for server-only deps.Define routes in dedicated route modules
defineRoutes(definition).create(({ defineRoute, config, deps, services }) => [ ... ])defineRoute options: method, path, inputSchema, outputSchema, handler,
errorCodes, queryParameters.input.valid() and request data helpers.json, jsonStream, empty, error.Server-side fragment instance (server entry module)
instantiate(definition).withConfig(config).withRoutes([ ... ]).withOptions(options).build()Client-side builder (client builder module)
createClientBuilder(definition, publicConfig, routes)createHook, createMutator.Framework client entrypoints (React/Vue/Svelte/Solid/Vanilla)
useFragno from @fragno-dev/core/<framework>.Each section below includes the intro excerpt from the docs plus definitions for key terms. For DB fragments, start with Database Integration Overview, then Database Testing before writing any tests.
curl -s "https://fragno.dev/api/search?query=defineRoutes"curl -L "https://fragno.dev/docs/fragno/for-library-authors/getting-started" -H "accept: text/markdown"Each section includes the docs intro and a curl command for the full page.
The config is the basic contract between the Fragment author and the user. It is used to pass configuration to the Fragment, such as API keys and options. It can also be used to let the user react to events happening in the Fragment by providing callback functions.
Dependencies are objects that are available to route handlers. They are provided using the
withDependencies method in the library definition. Dependencies are server-side only and are not
included in the client bundle. They are private to the Fragment and cannot be used by the user
directly.
Services are reusable business logic that can be exposed to Fragment users or shared between
Fragments. Like dependencies, services are server-side only and not included in the client bundle.
Fragments can both provide services (using providesService()) and require services (using
usesService()), enabling composition and modularity.
curl -L "https://fragno.dev/docs/fragno/for-library-authors/features/dependencies-and-services" -H "accept: text/markdown"The defineRoute function is the core building block for creating API endpoints. It provides a
type-safe way to define HTTP routes with validation, error handling, and automatic type inference.
curl -L "https://fragno.dev/docs/fragno/for-library-authors/features/route-definition" -H "accept: text/markdown"An important feature of Fragno is the ability to define client-side components as part of the Fragment. Under the hood, Fragno uses Nanostores to manage state. These reactive primitives integrate seamlessly with many popular frontend frameworks, such as React, Svelte, Vue, and vanilla JavaScript. Helper functions are provided to automatically create reactive stores for each API route. These are inspired by the popular TanStack Query library.
curl -L "https://fragno.dev/docs/fragno/for-library-authors/features/client-state-management" -H "accept: text/markdown"Fragments are "full-stack" libraries. As such, they contain both server-side and client-side components. Since frameworks differ in how they handle code splitting, Fragno must provide a way to split the code between client and server bundles on the Fragment level.
curl -L "https://fragno.dev/docs/fragno/for-library-authors/features/code-splitting" -H "accept: text/markdown"The @fragno-dev/db package provides an optional database layer for Fragments that need
persistent storage. This allows Fragment authors to define a type-safe schema while users provide
their existing database connection.
curl -L "https://fragno.dev/docs/fragno/for-library-authors/database-integration/overview" -H "accept: text/markdown"The Rules of Fragno are the default architectural constraints for database-backed fragments:
One handlerTx() per route (compose all reads/writes inside it)
Webhook routes are thin; durable hooks do the work
idColumn() is the app-facing ID (it can be external, but doesn't have to)
Full docs:
curl -L "https://fragno.dev/docs/fragno/for-library-authors/rules-of-fragno" -H "accept: text/markdown"
Local reference: references/rules-of-fragno.md
Use this when designing a fragment’s data model first. Fragno does not support arbitrary joins; your schema must explicitly encode the query graph you need.
references/data-model-and-queries.mdLearn how to define type-safe database schemas with the append-only log approach.
curl -L "https://fragno.dev/docs/fragno/for-library-authors/database-integration/defining-schemas" -H "accept: text/markdown"Fragno DB queries are type-safe and based on your schema. The recommended way to query is via the
Transaction Builder this.handlerTx() in route handlers, so reads/writes can be composed
and batched into a single transaction.
curl -L "https://fragno.dev/docs/fragno/for-library-authors/database-integration/querying" -H "accept: text/markdown"Durable hooks solve a common problem:
What if your database transaction commits, but your side effect (email, webhook, API call) fails?
With durable hooks, you register a hook trigger during the transaction. The trigger is persisted in the database as part of the same commit, and then the hook is executed after the commit. If execution fails, it's retried with an exponential backoff policy.
curl -L "https://fragno.dev/docs/fragno/for-library-authors/database-integration/durable-hooks" -H "accept: text/markdown"In the Fragno database layer, transactions are built around a two-phase pattern:
In terms of code organization, the important architectural rule is:
this.handlerTx()this.serviceTx(schema)This lets you call multiple service methods inside one transaction, and the DB work will be batched.
.check(): validation step inside a transaction to abort on invariants..check() patterns.curl -L "https://fragno.dev/docs/fragno/for-library-authors/database-integration/transactions" -H "accept: text/markdown"This section covers database test utilities, including usage of the in-memory adapter.
Important: Use the test harness below. It applies fragment migrations plus Fragno internal tables for hooks/outbox behavior and handles cleanup. Avoid copying internal adapters or migrations.
@fragno-dev/test).curl -L "https://fragno.dev/docs/fragno/for-library-authors/database-integration/testing" -H "accept: text/markdown"Fragno provides comprehensive testing utilities to help you test your fragments without running a
server. The createFragmentForTest function creates a test instance with type-safe route handling
and response parsing.
callRoute: typed helper to invoke routes without a server.json, jsonStream, empty, error).callRoute behavior.curl -L "https://fragno.dev/docs/fragno/for-library-authors/testing" -H "accept: text/markdown"When creating a Fragment using the create command with database support, the following assets will
automatically be created.
| Asset | What it is | Source |
|---|---|---|
database-index.ts | Complete database-backed fragment: definition, services, routes, client | ../../../packages/create/templates/optional/database/index.ts |
database-schema.ts | Schema definition with tables, columns, indexes, and relations | ../../../packages/create/templates/optional/database/schema.ts |
Converted and distributed by TomeVault — claim your Tome and manage your conversions.