Prerequisites
- A Veryfront project that imports
veryfront/extensions. - A concrete capability gap to fill.
denoavailable on your PATH.
Scaffold an extension
ext- directory
prefix. The capability and contract audit tasks only check extension directories
with that prefix. Local downstream extensions do not need it.
Write the factory
Provide a contract
Useprovides when the implementation does not need async setup:
setup(ctx) when the implementation opens resources or registers contracts
after async initialization.
Declare capabilities
Capabilities document runtime needs. Use a recognizedtype and matching scope
field so Veryfront can map the capability to a Deno permission flag and audit it
in CI.
| Type | Scope field | Deno permission |
|---|---|---|
fs:read | paths: string[] | --allow-read[=paths] |
fs:write | paths: string[] | --allow-write[=paths] |
net:outbound | hosts: string[] | --allow-net[=hosts] |
net:listen | host, ports[] | --allow-net=host:port,... |
env:read | keys: string[] | --allow-env[=keys] |
process:spawn | commands: string[] | --allow-run[=commands] |
native:ffi | none | --allow-ffi |
sandbox:execute | tools: string[] | Audit only |
capabilities array in deno.json
under veryfront.capabilities.
Understand load order
Veryfront loads extensions in this order:setup() runs in sorted order. teardown()
runs in reverse order during shutdown or reload.
Use presets to group extensions that load together:
veryfront.config.ts trigger teardown,
rediscovery, and setup. Release resources in teardown() so reloads do not leak
connections, timers, or file handles.
Test the extension
Test the factory first:Package the extension
Package an extension only when it needs reuse across projects.- Export the extension factory as the default export.
- Set
veryfront.extension: trueindeno.jsonorpackage.json. - Declare capabilities in package metadata and in the factory.
- Declare contract metadata through
contractsor staticprovides. - Include tests for the factory and contract implementation.
- Publish to npm or JSR.
Verify it worked
- Run
veryfront extension validate extensions/my-cache. - Run
deno test --no-check --allow-all extensions/my-cache/src/. - Add the factory to
veryfront.config.tsand restartveryfront dev. - Confirm the dev log lists the extension under its declared name.
- Resolve the contract from app code and confirm it uses the extension’s implementation.
Next
- Extensions: Enable an extension in a project
Related
- veryfront/extensions: Extension APIs
- veryfront/testing: Testing helpers