Edit

Props Reference

<LearnHouseActivity>

What to render

Pass one of activityId, activityName + courseId, activity or content.

PropType
activityIdstringActivity uuid (activity_…), fetched from the instance
activityNamestringFind the activity by name inside courseId (case-insensitive)
courseIdstringCourse uuid (course_…). Loads in parallel with activityId; lets media blocks find their files
activityLearnHouseActivityDataAn activity object you already have (from the API or @learnhouse/sdk)
contentActivityDocument | stringA document (TipTap JSON, as LearnHouse stores it), as an object or a JSON string

Instance

PropType
baseUrlstringThe instance's API address. Not needed inside LearnHouseProvider
tokenstringA user access token. Never an lh_ API token
orgIdstringOrg uuid, for media blocks when rendering content without fetching
siteUrlstringThe LearnHouse site's address, for the "Made with LearnHouse" link

Look

PropTypeDefault
themeLearnHouseThemeSee Theme
classNamestringAdded to the root element (.lh-activity)
styleCSSPropertiesMerged into the root element's style
unstyledbooleanfalseDon't set the theme variables
showTitlebooleanfalseShow the activity's name above it
headerReactNode | (activity) => ReactNodeAbove the content
footerReactNode | (activity) => ReactNodeBelow the content
showPoweredBybooleanfalseA small link back to the activity (needs siteUrl)

Content

PropType
componentsRecord<string, ComponentType<BlockOverrideProps>>Replace or wrap blocks by name. Block names
marksRecord<string, ComponentType<MarkOverrideProps>>Replace inline marks by name
hideBlocksstring[]Block names to leave out
transformContent(doc) => docRewrite the document before rendering

Behaviour

PropTypeDefault
linkTarget'_blank' | '_self' | '_parent' | '_top''_blank'Where links open
onLinkClick(href, event) => boolean | voidReturn false to cancel the navigation
trackCompletionbooleanfalseEmit complete when the end scrolls into view

Language

PropTypeDefault
localestring'en'One of 22 languages
messagesobjectString overrides, keyed like LearnHouse's locale files
dir'ltr' | 'rtl' | 'auto''auto'auto follows the locale

States & callbacks

PropType
fallbackReactNodeWhile loading the activity or a block's code
errorFallbackReactNode | (error, retry) => ReactNodeWhen loading or rendering fails
onLoad(activity) => voidThe activity is loaded
onError(error) => voidLoading or rendering failed
onEvent(event: LearnHouseEvent) => voidEvery event. See Events

<LearnHouseProvider>

PropType
baseUrlstringRequired. The instance's API address
mediaUrlstringWhere files are served from, if not baseUrl (a CDN or bucket)
clientLearnHouseClientYour own @learnhouse/sdk client (shared hooks, custom fetch)
tokenstringA user access token
getToken() => string | null | Promise<string | null>Called for each request; use it for tokens that refresh
userobjectThe signed-in user, for blocks that personalise
siteUrlstringThe LearnHouse site's address
theme, locale, messages, linkTargetDefaults for every activity below
onEvent(event) => voidEvents from every activity below

Exports

import {
  LearnHouseActivity,
  LearnHouseProvider,
  useLearnHouseClient, // the provider's @learnhouse/sdk client
  SUPPORTED_LOCALES,
  themeToStyle,        // theme object → CSS variables, for your own wrappers
  VERSION,             // the LearnHouse release this build matches
} from '@learnhouse/react'

import type {
  LearnHouseActivityProps,
  LearnHouseProviderProps,
  LearnHouseActivityData,
  ActivityDocument,
  LearnHouseTheme,
  LearnHouseEvent,
  BlockOverrideProps,
  MarkOverrideProps,
} from '@learnhouse/react'

Limits

  • One LearnHouse instance per page: media URLs follow the most recently mounted provider's baseUrl.
  • Assignments, SCORM packages and other activity types that need the course player aren't rendered; errorFallback is shown instead. Pages, videos, PDFs, markdown and embedded-URL activities are.