API reference
171 Meeko symbols grouped by what they are. Each page explains one with its exact type, generated from the source code, its parameters, real examples and the errors you get from misusing it.
- Components Meeko's built-in tags: you use them in the template without importing them, and the compiler checks their attributes. 9
-
Macros
The macros the compiler reads in the component script and the
define*functions that declare pages, middleware, plugins, modules, the configuration and the server. 18 -
Composables
use*functions that a component script calls at its top level: the route, the page, forms, the head, the theme, state and server data. 19 - Reactivity Signals, computed values, effects, lifecycle, context and error observers: the core, without a virtual DOM. 12
- Utilities Typed routes, redirects, API errors, generated clients, serialization, trusted HTML and passwords. 18
-
.meeko syntax
What the compiler recognizes in a
.meekofile: interpolation, directives, snippets and the component blocks. 14 - Server Sessions and their stores, security headers, OpenAPI, local calls, cross-instance Socket and process errors. 16
- Adapters How the built application runs on Node, Bun, Deno and Cloudflare Workers. 16
-
Commands
The
meekoCLI: development, checking, build, production server, new projects and tools. 15 -
Configuration
The keys of
meeko.config.ts, which is declared withdefineMeekoConfig. 14 - Advanced The pieces beneath the framework, for custom hosts, tools and tailored builds. 20
- All exports Every export of every module of the package, with its page generated from the JSDoc.
Components #
Meeko's built-in tags: you use them in the template without importing them, and the compiler checks their attributes.
-
<MeekoLink>Typed link to an application page that builds its href with href() and marks the current page or section with aria-current. -
<MeekoOutlet>Renders the inner layout or page in app/app.meeko and layouts, with the browser preserving the layout between routes. -
<MeekoAwait>A region for data arriving after the first paint, with loading, error and refresh states, and reserved height to prevent layout shifts. -
<MeekoTeleport>Renders content elsewhere in the document (the end of body or an element with an id) while keeping it in the declaring component. -
<MeekoPopover>Accessible popover anchored to its trigger, using the native popover API and CSS anchor positioning, for menus, lightweight dialogs and tooltips. -
<MeekoSelect>Unstyled accessible select built on MeekoPopover, with options of any type, multiple selection, search, groups and form submission. -
<MeekoThemeToggle>Accessible light/dark theme selector that does not jump on load and works without JavaScript, using themes from meeko.config.ts. -
<component is>Renders a component chosen by an expression, or since 1.5 an HTML tag, with type-checked props, events and snippets. -
ComponentRegistryDiscovers .meeko components by directory, queries their types and loads them by name.
Macros #
The macros the compiler reads in the component script and the define* functions that declare pages, middleware, plugins, modules, the configuration and the server.
-
definePropsDeclares component props with a TypeScript type and defaults, returning a reactive read-only view that also supports destructuring. -
defineEmitsDeclares a component's events with typed arguments and returns emit, which calls the parent's on:evento handler. -
defineModelDeclares a component model, a writable signal shared by the parent through model or model:nombre, or passed as a prop and an event, with an optional default value. -
defineSnippetsDeclares a component's snippets, template content written by the parent between its tags, with typed parameters. -
defineExposeExposes a component value, such as methods or signals, to the parent that names it with ref: and reads it with useElementRef. -
useElementRefReads the template element or component named with ref: from the script, as a signal or, with await, already mounted. -
definePageDeclares a page's route options (params and search schemas, rendering mode, loader, head, layout, middleware, cache and sitemap) with types flowing between them. -
defineGroupDeclares options in a +group.ts for an app/pages directory (named layout, its props and middleware) inherited by all its pages. -
defineRouteMiddlewareDeclares global or named route middleware in app/middleware, executed before the page in SSR and on each browser navigation. -
defineServerRouteMiddlewareDeclares route middleware running only on the server, with the request's session, before the page's server code. -
definePluginDeclares an application plugin in app/plugins, run at startup in the browser, on the server or both, and provides values to all components. -
defineMeekoConfigDeclares typed meeko.config.ts configuration (layers, modules, auto-imports, aliases, server, CSS, document, sitemap and theme) without changing it. -
defineMeekoModuleDeclares a Meeko module that configures the project from code when loading configuration, with merged options and the meeko object. -
defineApiRouteDeclares a server/api endpoint with public schemas, guards, status and handler; the server validates everything and generates the typed api.* client. -
defineRpcDeclares an RPC procedure in server/rpc with input and output schemas, guards and a handler, called by the application with typed rpc.*. -
defineServerMiddlewareDeclares HTTP middleware from server/middleware, wrapping pages, API and RPC before session creation and able to short-circuit or modify the response. -
defineSocketChannelDeclares a WebSocket channel in server/socket with schemas for each direction, per-room and per-event guards, and handlers for client messages. -
defineServerRuntimeDeclares sessions, services, Socket policy and application shutdown in server/runtime.ts, created once per process.
Composables #
use* functions that a component script calls at its top level: the route, the page, forms, the head, the theme, state and server data.
-
useRouteReads the committed route rendered by the component (url, path, id, params and search) as signals, and checks whether a route is active. -
usePageReturns the page request (url, params, search, request, context and signal) in the top-level code of its script server. -
useNavigationReturns the application's navigation state, with pending set to true while a new page loads. -
useFormComponent form state, with one signal per field, Standard Schema validation, server errors per field, submission and reset. -
useIdReturns an ID unique to each instance and call, identical in server HTML and during hydration, to link labels, controls and help text. -
useHeadAdds title, meta, link, script and style tags and html and body attributes to the document while the component is mounted. -
useSeoMetaTyped useHead shortcut for SEO that converts each field (description, Open Graph, Twitter, canonical) to the correct tag. -
useThemeReturns the application's light/dark theme (choice, effective theme and theme list) and changes it in html, the cookie and other tabs. -
useThemeTogglePublic state for a custom theme selector compatible with SSR, hydration and forms without JavaScript. -
useLayoutReads and changes the props of the page's enclosing named layout, with types and reactivity, from the page. -
useStateReturns the application's shared state signal for a key, created on first access, scoped per request in SSR and transferred to the browser. -
useStorageReturns a writable signal stored as JSON in localStorage or sessionStorage, without hydration mismatches and synchronized across tabs. -
useApiReads a server/api GET endpoint from a component, with SSR, hydration without repeating the request, reactive reloading and contract types. -
useApiMutationSends an on-demand POST, PUT, PATCH or DELETE request to a server/api endpoint, with pending state, errors and safe retries. -
useRpcQueryReads a server/rpc procedure from a component, with SSR, hydration, reactive input reloading and contract types. -
useRpcMutationCalls a data-changing server/rpc procedure on demand, with submission state, errors and safe retries. -
useSocketConnects a component to a server/socket channel with typed events and closes the connection on unmount. -
useSocketChannelOpens a channel by name from a Socket contract registry, bound to the component; this is the function used to generate the useSocket auto-import. -
useRequestStateStores a value in server request state, creating it on first access, to share it among middleware, loaders and handlers for that request.
Reactivity #
Signals, computed values, effects, lifecycle, context and error observers: the core, without a virtual DOM.
-
signalCreates an observable, writable value with .value; writing a different value notifies the template, computed values and effects that read it. -
computedDerives a read-only value from other signals and recalculates it as soon as any signal it read changes. -
effectRuns a synchronous function now and whenever a signal it read changes; returns the function that stops it. -
batchGroups multiple signal writes into a single round of notifications when the function finishes. -
untrackRuns a function that reads signals without tracking them as dependencies of the active observer. -
onMountedRuns a function once in the browser after the component has hydrated or mounted; never in SSR. -
onCleanupRegisters synchronous resource cleanup in the active root, executed when the component unmounts or is disposed of. -
createContextCreates a unique, typed key for sharing a value with descendants through provide and inject. -
provideProvides a value under a context key in the active component and all its descendants. -
injectReads the value provided with provide by the nearest ancestor and fails if none provided it. -
createRootCreates a reactive root whose effects, cleanups and contexts are disposed of together when you call dispose. -
provideErrorHandlerRegisters the browser failure observer for a component and its entire branch, with each failure's source.
Utilities #
Typed routes, redirects, API errors, generated clients, serialization, trusted HTML and passwords.
-
hrefBuilds an application route's URL from its ID, with encoded parameters and the query string, checked by TypeScript. -
redirectStops page server code or server route middleware and responds with a redirect, which client navigation follows in the same way. -
notFoundStops the page's server code or server route middleware and displays the nearest error page with status 404. -
deferMarks loader or page server code data that can arrive after the first byte with render stream, with reactive state. -
apiGenerated client for server/api endpoints, typed by their schemas, working the same way in the browser and on the server. -
rpcGenerated client for server/rpc procedures, typed by their input and output schemas, that works the same in the browser and on the server. -
socketGenerated registry of server/socket channels, with typed on and emit in the browser and typed broadcast on the server. -
ApiErrorPublic API, RPC, Socket and loader error, delivered to the client with its code, status and, since 1.5, field messages. -
ClientErrorThe error API, RPC and Socket clients use to reject an error response from the server, with its code, status, requestId and per-field issues. -
isClientErrorChecks whether an unknown value is a ClientError and optionally has a specific code, including across two copies of Meeko. -
PageInputErrorThe error for a page whose params or search fail the definePage schemas, returned by the server as 400 and displayed in the browser through the error page. -
serializeJsonSerializes a value into JSON safe to insert in a script tag, checking faithful representation and escaping anything that could close the tag. -
trustHtmlDeclares HTML trusted and gives it the TrustedHtml type, which the html directive accepts without a warning; does not sanitize or copy anything. -
isTooLargeToAnimateTells whether a document is too large to animate with a View Transition; navigations and withViewTransition already check it. -
documentHtmlMakes trusted HTML travel only once on the first load, in the document's HTML and not also in the hydration payload. -
hashPasswordComputes a password's scrypt hash in a self-describing format, ready to store in a column or .env. -
verifyPasswordChecks a password against a stored scrypt hash in constant time, recomputing it with the hash's own parameters. -
needsRehashIndicates whether a password hash needs recalculating with the current hashPassword parameters, to update it after a successful login.
.meeko syntax #
What the compiler recognizes in a .meeko file: interpolation, directives, snippets and the component blocks.
-
{expresión}Inserts a TypeScript expression's value into the template as escaped text, updated when the signals it reads change. -
if:whenRenders a tag and its content only while an expression is truthy, and narrows types inside it. -
each:ofRepeats a tag for each item in a list, with its name, index and, if needed, a stable key per row. -
on:eventoListens to a DOM event on an element or a defineEmits event on a component, with typed event and currentTarget. -
bind:nombreSets an element attribute or component prop to an expression's value and updates it when its signals change. -
modelCreates a two-way binding between a form control or component model and a writable signal. -
htmlFills an element with unescaped HTML from an expression, which must be marked as trusted with trustHtml. -
ref:nombreNames a template element or component so the script can read it with useElementRef, typed from its tag or defineExpose. -
<snippet>Fills a named snippet declared by a child component with defineSnippets from the parent, with typed parameters. -
<render>Renders a snippet passed by the parent inside a component, with the arguments supplied by the child. -
<script server>A page's server code inside its .meeko file, with route options and typed JSON data exported to the template. -
genericDeclares component type parameters in its script, inferred by the parent from props and used to type events, models, snippets and refs. -
<style>Global styles colocated with the component that needs them, processed by the application's PostCSS and bundled with it. -
<style scoped>Component scoped styles, limited to its template elements with a data-meeko-s attribute, and :global(…) to escape the scope.
Server #
Sessions and their stores, security headers, OpenAPI, local calls, cross-instance Socket and process errors.
-
SessionManagerApplication session manager with opaque HttpOnly cookies, family-based rotation and revocation, and Origin and CSRF checks on authenticated mutations. -
SessionHandleA request's session, in context.session, to read, create, rotate, revoke and verify before an irreversible effect. -
MemorySessionStoreSession store in process memory, only for development, tests and prerendering; not persistent and rejected by SessionManager in production. -
RedisSessionStorePersistent Redis session store, with Redis expiration, atomic rotation and revocation, cross-instance revocation and shared rateLimit counters. -
SqlSessionStorePersistent session store over any SQL database, using statements from an application driver and, since 1.7, rateLimit counters in the database. -
SessionRevokedErrorThe 401 SESSION_REVOKED ApiError for a session revoked, rotated or expired during the request, and the abort reason of context.signal. -
SessionSecurityErrorA mutation failed the session's Origin or CSRF check, with code INVALID_ORIGIN or INVALID_CSRF; API and RPC responses convert it to 403. -
contentSecurityPolicyBuilds the Content-Security-Policy header from a directive-based policy and adds the hashes of a page's inline scripts and styles. -
generateOpenApiGenerates an OpenAPI 3.1 document for the application's API and RPC endpoints from an explicit registry of public schemas. -
createLocalCallsCalls the application's API and RPC inside the process, using the current request's credentials and the same guards, validation and limits as HTTP. -
createLocalServerFetchThe local dispatch used by api and rpc clients during SSR, serving calls through the HTTP pipeline without leaving the process and only with the current request's origin and credentials. -
LocalSocketPubSubSocket broadcast broker within a single process, used by the hub by default in Node, Bun and Deno; does not reach other instances. -
RedisSocketPubSubDistributes Socket broadcasts across multiple instances or processes with Redis pub/sub, including sharded pub/sub in Redis Cluster. -
composeServerMiddlewareComposes a list of server middleware around a Fetch handler, from outside in, as Meeko does with server/middleware files. -
handleProcessErrorsApplies server/runtime.ts processErrors policy to a custom host for unhandled rejections and uncaught exceptions outside a request. -
errorResponseConverts any error into Meeko's public JSON response, { code, status, requestId }, without leaking unexpected error messages.
Adapters #
How the built application runs on Node, Bun, Deno and Cloudflare Workers.
-
serveNodeServes a Meeko application with Node's HTTP server, its Socket channels with ws, graceful shutdown on signals and the process failure policy. -
toNodeListenerAdapts a Fetch handler to Node's http.createServer callback, with streaming, multiple Set-Cookie headers, cancellation on client disconnect and the connection's IP. -
attachNodeWebSocketServerConnects Meeko Socket channels to a Node HTTP server through the ws package, with a frame limit, heartbeat and shutdown of all peers. -
createNodeAssetReaderServes only build files listed in the asset manifest from disk on Node, using streaming and Meeko's ETag, HEAD, 304 and cache policy. -
createNodeSocketUpgradeHandlerChecks Socket upgrade policy in Node's upgrade event and leaves framing to the host's chosen WebSocket library. -
createBunServerThe fetch and websocket handlers for serving a Meeko application with Bun.serve, using Bun's native WebSocket for Socket and its payload, backpressure and idle limits. -
createBunAssetReaderServes only build files listed in the asset manifest through Bun.file, with ETag, HEAD, 304 and Meeko's cache policy. -
serveDenoServes a Meeko application with Deno.serve, with Socket over Deno.upgradeWebSocket, graceful shutdown on signals and the process failure policy. -
createDenoAssetReaderStreams only build files listed in the asset manifest using Deno.open, with ETag, HEAD, 304 and Meeko's cache policy. -
createWorkerServes a Meeko application from a Cloudflare module Worker, created once per isolate with its bindings, forwarding Socket upgrades to their room's Durable Object. -
createSocketRoomClassCreates the Durable Object class hosting a Socket room's WebSockets in Cloudflare Workers, with the hibernation API, reconstruction on wake and per-room limits. -
socketRoomNameThe Durable Object name of a Socket room in Cloudflare Workers, with one object per channel and room, for idFromName. -
DurableObjectSocketPubSubThe Socket broker for Cloudflare Workers, where each channel and room is a Durable Object that receives publications over RPC and distributes them to its peers. -
D1SessionDriverSqlSessionStore driver for Cloudflare D1, with atomic rotation and revocation, expired-row cleanup and, since 1.7, rateLimit counters shared across isolates. -
createCloudflareAssetReaderServes only build files listed in the manifest from Cloudflare's Static Assets binding, with the ETag, HEAD, 304 and caching behavior of the other adapters. -
createCloudflarePrerenderSourceA Worker's prerendered pages, read from the Static Assets binding once per isolate, with their navigation payload and CSP hashes.
Commands #
The meeko CLI: development, checking, build, production server, new projects and tools.
-
meeko devDevelopment server for a full-stack application, preparing .meeko/ types and serving the application with Vite, SSR and HMR. -
meeko buildChecks the project and writes production output to .meeko/output/<adaptador>/, including the client, server and prerendered pages. -
meeko startStarts the Node production server using meeko build output, without Vite or application sources. -
meeko previewRuns meeko build output in its real runtime (Node, Bun, Deno, wrangler dev or a file server) to test it before deployment. -
meeko checkChecks an entire project, or a single .meeko component, with Meeko and TypeScript diagnostics, and generates .meeko/ types. -
meeko cleanDeletes Meeko-generated files in a project (.meeko/ and the Vite cache) and, with --all, node_modules too, without ever following links. -
meeko initCreates a standalone SSR project without the framework, with a .meeko component, its Node server and Vite. -
meeko init-frameworkCreates a full-stack Meeko application with meeko.config.ts, app/, a layout, a prerendered page, .env.example and CLI scripts. -
meeko auth hashPrompts for a password without echoing it, or reads it from stdin, and prints its scrypt hash for storage in .env or the database. -
meeko routesDiscovers routes, server contracts, components and auto-imports and prepares .meeko/ like meeko check (manifests, declarations and tsconfig), without running TypeScript. -
meeko prerenderPrerenders render "prerender" routes again using the existing Node build, without recompiling, and writes .meeko/output/node/prerender/. -
meeko compileChecks a .meeko component and compiles it to a TypeScript module with its server render, hydration and types. -
meeko typesGenerates a component's .d.meeko.ts declaration and those of its imported components in .meeko/types/, so TypeScript can check their props. -
meeko check-appChecks all .meeko components in the application and its layers, without generating .meeko/ or checking .ts files with TypeScript. -
meeko lspStarts the language server for .meeko components, used by VS Code, Neovim, Helix, Zed and JetBrains.
Configuration #
The keys of meeko.config.ts, which is declared with defineMeekoConfig.
-
layersProject folders that contribute pages, components, auto-imports, layouts and plugins to the application, in the listed order. -
extendsThe former name of layers, still supported in 1.x without a warning; its folders come before those in layers. -
modulesNames of modules created with defineMeekoModule that configure the project through code; each module's options go under its key (meta.configKey). -
importsAuto-import folders in addition to the defaults, each with the scope of its containing folder, app, shared or server. -
aliasCustom path aliases, or changes to ~/, @/, #shared/ and #server/, used in Vite, generated tsconfig files, the editor and @utilities. -
serverThe meeko build adapter (node, bun, deno, cloudflare or static) and its options, plus, since 1.7, response CSP and headers for server adapters. -
cssComponent style options, such as which elements receive the scoped style attribute, all elements or only those that some selector can match. -
documentThe application's shared HTML document, with html lang, head tags for all pages, per-page canonical and Open Graph tags and the useId prefix. -
devOptions for meeko dev, such as forwarding server code output to the browser console while handling a request. -
devtoolsMounts the Meeko DevTools panel inside the page in meeko dev, without application code, in the chosen corner. -
siteThe site's public URL, of which only the origin is used, for absolute URLs in sitemap.xml, robots.txt and document.seo. -
sitemapWrites sitemap.xml during the build with prerendered pages, routes without parameters and, since 1.7, sitemapEntries URLs from dynamic routes. -
robotsWrites robots.txt during the build with User-agent wildcard rules and, with sitemap, the absolute sitemap URL. -
themeFlicker-free light, dark or custom application themes, with the choice in a cookie, the theme on html from the first byte and useTheme in components.
Advanced #
The pieces beneath the framework, for custom hosts, tools and tailored builds.
-
createServerAppCreates the portable server application (pages, API, RPC, Socket, assets, sessions and middleware) from the build manifest and a module loader. -
createFrameworkHandlerCreates a Fetch handler rendering application pages (route middleware, validation, loader, SSR, navigation payload and error pages) for a custom host. -
createServerDispatcherCreates an HTTP handler that serves /api/... and /_meeko/rpc/... on your own host, with the same sessions, guards, validation and errors as the application. -
createRequestContextCreates a request's RequestContext (session, services, platform, requestId and signal) for a custom host or to test an endpoint without a server. -
createSocketHubCreates the Socket hub for a custom host, authorizing handshakes, accepting connections, validating events and distributing broadcasts across rooms and instances. -
createSocketUpgradeHandlerPortable Socket handshake, validating the channel path, running hub checks and connecting the runtime's WebSocket to the hub. -
mountClientAppHydrates server-rendered HTML in the browser and manages client navigation, with history, links, route middleware, data payloads and cleanup. -
createNavigatorLow-level client navigator for a custom host, resolving routes, updating history and handling popstate while delegating rendering to a callback. -
createApiClientCreates a typed API endpoint client from its public manifest, without importing server code, for explicit, external or test clients. -
createRpcClientCreates a typed RPC procedure client from its public manifest, where each call is a JSON POST with the CSRF token. -
createSocketClientLow-level Socket client over native WebSocket, with explicit URL and contract, validation in both directions and exponential backoff reconnection. -
useSocketClientCreates a component's Socket client with explicit URL and contract, closing it on unmount and using its error observer. -
StateStoreStores useState state, with one signal per key and JSON-serializable values, created per request on the server and transferred to the browser. -
matchRouteFinds a URL's route in the route manifest, using the same criteria as SSR and client navigation, and returns its decoded parameters. -
buildProjectBuilds the project like meeko build, without the preliminary check, and returns the adapter and output folder; for build scripts and tools. -
prerenderRoutesPrerenders render "prerender" routes with a page handler and writes their HTML, navigation payloads and manifest.json index. -
loadMeekoConfigLoads and validates a project's meeko.config.ts (or .mts, .js, .mjs) with Node 24 and returns its configuration, or {} if absent. -
meeko (Vite)Meeko's Vite plugin, compiling .meeko imports for the client and SSR, adding HMR and CSS in development, applying auto-imports and generating framework virtual modules. -
meekoUtilitiesPostCSS plugin that replaces each @utilities "<ruta>" with CSS rules generated by a TypeScript function, with HMR in meeko dev and the project's auto-imports. -
mountDevtoolsPanelMounts the Meeko DevTools panel in the page, isolated in Shadow DOM, with the instance tree, editable signals, timeline and breakpoints.
All exports #
The types, interfaces and low-level pieces that have no entry of their own above are still documented, one per page, in the index by module.
- Sintaxis de .meeko
-
@meekojs/meeko -
@meekojs/meeko/framework -
@meekojs/meeko/server -
@meekojs/meeko/node -
@meekojs/meeko/password -
@meekojs/meeko/bun -
@meekojs/meeko/deno -
@meekojs/meeko/cloudflare -
@meekojs/meeko/build -
@meekojs/meeko/vite -
@meekojs/meeko/prettier -
@meekojs/meeko/postcss -
@meekojs/meeko/devtools-ui -
@meekojs/meeko/compiler -
@meekojs/meeko/parse -
@meekojs/meeko/i18n -
@meekojs/meeko/i18n/module