Skip to content

Framework API

Core functions exported from src/framework/index.js.


createApp(options?)

Initialises the application and mounts it to the DOM.

Source: src/framework/app.js

js
import { createApp } from './framework/index.js'

await createApp({ root: '#app' })

Parameters

NameTypeDefaultDescription
options.rootstring'#app'CSS selector for the root DOM element
options.pluginsarray[]Plugin objects with an optional install() method

Returns: Promise<void> — resolves after the initial render.

Must be awaited. Call after initRouter().


createStore(setup)

Creates a reactive state store. A thin wrapper around Arrow.js reactive() that encourages declaring store shape via a setup function.

Source: src/framework/store.js

js
import { createStore } from '../framework/index.js'

export const counterState = createStore((reactive) =>
  reactive({
    count: 0,
    increment() { this.count++ },
  })
)

Parameters

NameTypeDescription
setup(reactive) => objectReceives Arrow.js reactive and returns the store object

Returns: The object returned by setup.


provide(key, value)

Registers a value in the app-level dependency injection context.

Source: src/framework/context.js

js
import { provide } from './framework/index.js'

provide('app', { name: 'My App', tagline: 'Powered by Quiver' })

Parameters

NameTypeDescription
keystringUnique lookup key
valueanyValue to store — can be an object, primitive, or function

Returns: void

Call in src/main.js before createApp(). A key can be overwritten by calling provide again with the same key.


inject(key, fallback?)

Retrieves a value from the app-level DI context.

Source: src/framework/context.js

js
import { inject } from '../framework/index.js'

export function MenuLayout(content) {
  const app = inject('app', { name: 'Quiver', tagline: '' })
  // ...
}

Parameters

NameTypeDescription
keystringKey to look up
fallbackanyValue returned when the key has not been provided

Returns: The provided value, or fallback if the key is not found.

Must be called inside a function body — not at module scope — to avoid circular import issues between framework/index.js and layout/component files.


useMeta(options)

Sets document.title and/or the <meta name="description"> tag. Accepts static strings or reactive arrow functions.

Source: src/framework/meta.js

js
import { useMeta } from '../framework/index.js'

function MyPage() {
  useMeta({ title: 'My Page', description: 'Page description.' })
  return html`...`
}

Parameters

NameTypeDescription
options.titlestring | () => stringDocument title. A function is re-evaluated reactively via watch().
options.descriptionstring | () => stringMeta description content. A function is re-evaluated reactively.

Returns: void

Note: For static page titles you do not need useMeta — declare export const meta = { title } in your page module and the router sets document.title automatically on every navigation. Use useMeta only when the title must be reactive (e.g. derived from route params or state).