Need UI components? For buttons, inputs, layouts, and charts, see the Extension Kit Components guide.
All imports come from @teachfloor/extension-kit, which is automatically installed when you create an app.
Signaling App Ready
Basic Usage
Signal to the platform that your app is ready:
Code
import { initialize } from '@teachfloor/extension-kit'function App() { useEffect(() => { initialize() // Signal app is ready }, []) return <div>My App</div>}
With Context Provider
Code
import { ExtensionContextProvider } from '@teachfloor/extension-kit'// The provider signals readiness automatically<ExtensionContextProvider autoInit={true}> <App /></ExtensionContextProvider>
API Reference
Events
Subscribe to Events
Listen to platform events using subscribeToEvent(). Events receive two parameters: the event data and an objectContext containing contextual information based on your app's permissions.
Code
import { subscribeToEvent } from '@teachfloor/extension-kit'// Viewport changes - objectContext includes course/module/element based on permissionssubscribeToEvent('environment.viewport.changed', (viewport, objectContext) => { console.log('User navigated to:', viewport) if (objectContext.course) { console.log('Course:', objectContext.course.name) } if (objectContext.module) { console.log('Module:', objectContext.module.name) } if (objectContext.element) { console.log('Element:', objectContext.element.name) }})// Path changes - single parametersubscribeToEvent('environment.path.changed', (path) => { console.log('Path changed:', path)})// User events - objectContext includes contextual datasubscribeToEvent('auth.user.event', (eventData, objectContext) => { console.log('User event:', eventData.type) if (objectContext.course) { console.log('Happened in course:', objectContext.course.name) }})
Available Events:
Event
Parameters
Description
environment.viewport.changed
(viewport, objectContext)
User navigated to a different viewport. objectContext contains course/module/element data based on permissions.
Objects are only present when the permission is granted and the viewport context matches.
How it works:
Objects are included based on two conditions:
Permission granted: Your app must have the corresponding permission declared in the manifest
Relevant context: The current viewport/path must be within that context
When both conditions are met, the complete object is included. Otherwise, the key is not present in the object.
Example:
Code
// With course_read permission on a course detail page:{ course: { id: "abc123", name: "Introduction to React", /* ...other course fields */ } // module and element keys not present (not in their context)}// Without course_read permission on a course detail page:{ // No keys present (no permissions granted)}// With course_read and module_read on a module detail page:{ course: { id: "abc123", name: "Introduction to React", /* ...other course fields */ }, module: { id: "def456", name: "Getting Started", /* ...other module fields */ } // element key not present (not in element context)}
See Permissions for details on requesting access to course, module, and element data.
Data Storage
The Extension Kit provides store(), retrieve(), and createCollection() functions for persisting data. Three types of storage are available: app data (organization-wide), user data (user-specific), and user collections (paginated lists).
See Data Storage for complete documentation, API reference, and usage examples.