Use when creating code examples for documentation pages - JavaScript, TypeScript, React, Angular, and Vue variants with proper imports, registration, and license key
This skill covers how to write runnable code examples that are embedded in documentation guide pages.
Each guide has framework-specific subdirectories for its examples:
docs/content/guides/category/feature/
feature.md # The guide page
javascript/ # JS examples
example1.js # Generated from TS - do not edit directly
example1.ts # Primary source - edit this first
react/ # React variants
example1.jsx # Generated from TSX
example1.tsx # Primary source
angular/ # Angular variants
example1.ts
example1.html # Template file
vue/ # Vue 3 variants
example1.js
example1.html # Template file
example1 = basic setup, example2 = a configuration variation, example3 = advanced usage..ts / .tsx file first. From docs/, generate the JS variant with: npm run docs:code-examples:generate-js -- <path-to-ts-file> (path relative to docs/). Never hand-edit generated JS files.createSpreadsheetData() or domain-appropriate sample data (product names, dates, currencies). Avoid trivial arrays like [1, 2, 3].Imports - use the base import and explicit registration:
import Handsontable from 'handsontable/base';
import { registerAllModules } from 'handsontable/registry';
registerAllModules();
For examples that demonstrate tree-shaking, import individual plugins and cell types instead of registerAllModules().
License key - always include:
licenseKey: 'non-commercial-and-evaluation'
Container element - target the conventional #example div:
const container = document.querySelector('#example');
React (TSX/JSX):
import { HotTable } from '@handsontable/react-wrapper';
import { registerAllModules } from 'handsontable/registry';
registerAllModules();
const App = () => {
return <HotTable data={data} licenseKey="non-commercial-and-evaluation" />;
};
Angular:
.ts file..html file using <hot-table>.Vue 3:
.js file..html file using <hot-table>.After creating example files, embed them in the guide's .md file using the @[code] directive inside an ::: example container. See the writing-docs-pages skill for the full embedding syntax.
licenseKey: 'non-commercial-and-evaluation' present.handsontable/base + registration pattern.