Under the hood
This is the machinery a course is built on. If you write courses by hand, it's your map; if your assistant does the building, it shows what's possible when a project pushes past the defaults. For exact signatures and every option, see the full reference that ships inside Tessera.
Course structure
A course is a folder. Its sections, lessons, and pages come straight from the
folders and files inside pages/:
product-101/
├── course.config.js # title, language, settings
├── pages/
│ └── 01-safety/ # a section
│ ├── _meta.js # section title
│ └── 01-hazards/ # a lesson
│ ├── _meta.js # lesson title and page order
│ ├── welcome.svelte # a page
│ └── check.svelte # a quiz page
├── components/ # your own components
├── assets/ # images, audio, video
└── styles/ # CSS overrides
Folders sort alphabetically, so a numeric prefix like 01- sets the
order and is stripped from the page's URL. Every section and lesson folder with
pages needs a _meta.js that gives its title, and can set the page order
within it. Pages can also sit directly in a section folder, without a lesson.
Each page is a Svelte file, and plain HTML works as-is. Its pageConfig
gives the page its title and can turn the page into a quiz. Titles are never made
from file or folder names, so a missing one stops the build:
<script module>
export const pageConfig = { title: 'Spotting hazards' };
</script>
<script>
import { Callout, MultipleChoice } from 'tessera-learn';
</script>
<h1>Spotting hazards</h1>
<Callout type="tip"><p>Most trips happen near doorways.</p></Callout>
<MultipleChoice
id="report"
question="Which of these should you report?"
options={['Blocked fire exit', 'Wet floor with signage']}
correct={0}
/>
Built-in components
Pages import only the components they use, all from tessera-learn.
Every one is keyboard-accessible with correct ARIA out of the box.
- Content:
Callout,Image,Accordion,Carousel,RevealModal,Video, andAudio. - Questions:
MultipleChoice,FillInTheBlank,Matching, andSorting. They work inline on any page, as practice or graded, or as a quiz when the page setspageConfig.quiz.
Every question needs an id that is unique on its page. The id keys the
learner's saved answer and the question's record in the LMS, so keep it when you
reword the question.
Course configuration
Each course has one configuration file, course.config.js, covering
title and identity, language, logo, navigation mode (free or sequential), the
completion rule, what counts as a pass, the passing score, the export standard, and
accessibility strictness. Only the title and language are required; everything else
has a sensible default. The config is data only: anything that has to be a function,
like custom access rules or xAPI credential lookups, goes in a companion
course.runtime.js. Your assistant edits it from sentences like "make navigation sequential and
raise the pass mark to 80".
The hooks API
Seven hooks are the stable contract between custom components and the runtime:
useQuestion (questions), useQuiz (quiz control),
useNavigation, useProgress, useCompletion,
usePersistence (saved state), and useCourse (course
identity). The built-in components are built on these same hooks, so anything a
built-in does, a custom component can do too. The point of the design: a custom
widget that registers through useQuestion is scored, persisted, and
reported to the LMS identically to a built-in question type. Custom work
is never tracking-blind.
<script>
import { useQuestion } from 'tessera-learn';
let clicked = $state([]);
// registers with scoring, tracking, and resume
const q = useQuestion({
id: 'trip_hazards',
text: 'Click the two tripping hazards.',
response: () => ({ type: 'choice', response: clicked, correct: ['cable', 'box'] }),
reset: () => (clicked = []),
restore: (saved) => (clicked = saved),
});
</script>
<!-- your markup, your styles -->
<button onclick={q.submit} disabled={q.submitted}>Submit</button>
{#if q.canRetry}<button onclick={q.retry}>Try again</button>{/if}
The text is the question as the learner reads it, and it shows in LMS
reports. The built-in QuestionReview component can draw the Submit
button, result, and Try again for you, the same way the built-in questions do.
usePersistence is worth calling out: a custom interaction can persist a
learner's in-progress work, and it survives a reload or a return the next day on
every export target, browser storage on the web, the LMS's own saved state under
SCORM, and the record store's under cmi5 and xAPI. A half-finished interaction
resumes exactly where the learner left off, with no work on your part beyond
storing the value.
Custom layouts and quiz shells
Two drop-in files change a course's chrome without forking anything:
layout.svelte replaces the default sidebar-and-topbar shell, and
quiz.svelte replaces the quiz presentation while the underlying
scoring machinery stays put. A custom layout can also wrap the default one
instead of starting from scratch.
Custom access rules
Beyond free and sequential navigation, a course can define its own access logic:
prerequisites, unlocking a module only after a specific quiz score, time-based
gating. It's a small function in course.runtime.js with full access to
progress and course structure.
xAPI destinations
Components send custom xAPI statements through the useXAPI() hook.
They can flow to the LMS's own record store (for cmi5/xAPI launches), to an external
LRS, or fan out to several destinations at once, each with its own id, queueing, and
retry. Statements carry learner identity automatically, on
SCORM exports too, where the runtime derives the actor from the LMS session. One
hard rule: course.config.js and course.runtime.js both ship
inside the package where anyone can read them, so LRS credentials must come from a
token endpoint, fetched by a function in course.runtime.js, never be
pasted into either file.
Assets and styling
Media lives in an assets/ folder per course and is referenced through
the $assets/ alias, which is checked at build time: a missing file is
reported instead of silently shipping a broken image.
Styling lives in the course's styles/ folder. Brand colour, font, and
the rest of the theme are --tessera-* CSS custom properties set on
:root, such as --tessera-primary and
--tessera-font-family, and any plain rule in styles/
overrides a built-in component's style. A light brand colour or a dark theme needs a
few more of these set so text stays readable; the authoring guide lists which.
Build customisation
The build itself is owned by Tessera (there's no bundler config to maintain), with
two escape hatches: tessera.config.js merges partial build settings on
top, and web exports emit a baseline Content-Security-Policy that can be extended
when a course legitimately loads external fonts or media.
The guardrails
A few constraints keep courses portable and updatable, and they apply whether you or your assistant writes the code: page content is static (no runtime data fetching inside pages), only the public API is used (never internal paths that change between versions), and framework behaviour is extended through the extension points above, never by patching installed files.
The full reference
The canonical specification ships inside every workspace, in
node_modules/tessera-learn/, and always matches the version you have
installed. It's written for your assistant, but it's readable, and if you want to
know exactly how something works, it's the source of truth:
- AGENTS.md: course structure, every built-in component and its props, config fields, and commands.
- hooks.md: full signatures for all seven hooks.
- recipes.md: complete custom questions, quiz shells, and layouts.
- scoring.md: graded pages, weighting, pass/fail, and manual completion.
- xapi.md: custom xAPI statements and extra record stores.
- export.md: export packages, supported browsers, and how each LMS standard behaves.