Get started with SFM
[!WARNING] The SFM npm package has not been released. The steps below describe the preview integration. Installation instructions will be available when the package is released.
Try the live demo before setting up your own page.
Start with a Markdown file
Section titled “Start with a Markdown file”Save this example as launch-checklist.md in Space. Serve the file from your app at /documents/launch-checklist.md.
## Launch checklist
- [x] Confirm the schedule- [ ] Review the release notes
Keep the ==approved draft== handy.Mount the reader
Section titled “Mount the reader”Give the reader its own HTML element.
<article id="sfm-document"></article>Load the document stylesheet on the same page and run this code as a browser module. The example assumes your preview integration provides render. See the browser entry points.
const container = document.getElementById("sfm-document");if (!container) throw new Error("Missing SFM mount");
const response = await fetch("/documents/launch-checklist.md");if (!response.ok) throw new Error(`Markdown request failed: ${response.status}`);
const source = await response.text();const reader = render(container, source, { appearance: "auto", outlineMode: "off",});The reader owns the contents of the article. Keep app controls outside it. When the view is removed, call reader.destroy(). See reader lifecycle and themes and attachment resolution.
Live demo
Section titled “Live demo”Edit the Markdown or choose an example to see it rendered. The source stays in this tab.
Rendered preview
Enter some Markdown to see the preview.