1. Introduction
  2. Guidance
  3. 1. Get started
  4. 2. Bundles
    1. 2.1. All-in-One Library for Browsers
    2. 2.2. All-in-One Library for Node.js
  5. 3. Compilers
    1. 3.1. (Pre-)Compiler in CLI
    2. 3.2. Compiler in Rust
    3. 3.3. Compiler in Node.js
    4. 3.4. Compiler in Wasm (Web)
  6. 4. Renderers
    1. 4.1. Renderer in Rust
    2. 4.2. Renderer in Node.js
    3. 4.3. Renderer in Wasm (Web)
    4. 4.4. Renderer in React
    5. 4.5. Renderer in Solid
    6. 4.6. Renderer in Angular
    7. 4.7. Renderer in Vue3
    8. 4.8. Hexo Plugin
  7. 5. Samples
    1. 5.1. Static, Responsive rendering
    2. 5.2. Streaming, Incremental rendering
    3. 5.3. Serverless rendering
  8. 6. Trouble Shooting
  9. Project samples
  10. 8. shiroa
  11. 9. typst-preview
  12. 10. hexo-renderer-typst
  13. References
  14. 13. Routing to Renferences

reflexo-typst Documentation

Claim: the Typst compiling functions is provided by official typst

Example Application: single-file

Run the entire typst directly in browser, like typst.app.

#

Key Descriptions

It uses All-in-one (Simplified) Library for Browsers, using a single bundle for both compiler and renderer. Thought it is less flexible and stable than the underlying interfaces, it is pretty easy. The simplified library also teaches you how to use the underlying interfaces for better performance.


        
<script

        
  type="module"

        
  src="https://cdn.jsdelivr.net/npm/@myriaddreamin/typst.ts/dist/esm/contrib/all-in-one-lite.bundle.js"

        
  id="typst"

        
></script>

        
<script

        
  type="module"

        
  src="https://cdn.jsdelivr.net/npm/@myriaddreamin/typst.ts/dist/esm/contrib/all-in-one-lite.bundle.js"

        
  id="typst"

        
></script>

A <textarea> is used to input the typst document, and a <div> is used to render the document.


        
<textarea id="input">Hello, Typst!</textarea>

        
<div id="content"></div>

        
<textarea id="input">Hello, Typst!</textarea>

        
<div id="content"></div>

To load wasm modules compiled from Rust from CDN, you need to set the module path for the compiler and renderer:


        
$typst.setCompilerInitOptions({

        
  getModule: () =>

        
    'https://cdn.jsdelivr.net/npm/@myriaddreamin/typst-ts-web-compiler/pkg/typst_ts_web_compiler_bg.wasm',

        
});

        
$typst.setRendererInitOptions({

        
  getModule: () =>

        
    'https://cdn.jsdelivr.net/npm/@myriaddreamin/typst-ts-renderer/pkg/typst_ts_renderer_bg.wasm',

        
});

        
$typst.setCompilerInitOptions({

        
  getModule: () =>

        
    'https://cdn.jsdelivr.net/npm/@myriaddreamin/typst-ts-web-compiler/pkg/typst_ts_web_compiler_bg.wasm',

        
});

        
$typst.setRendererInitOptions({

        
  getModule: () =>

        
    'https://cdn.jsdelivr.net/npm/@myriaddreamin/typst-ts-renderer/pkg/typst_ts_renderer_bg.wasm',

        
});

Sets input event handler and performs a first-time rendering:


        
input.oninput = () => {

        
  previewSvg(input.value);

        
  input.style.height = '5px';

        
  input.style.height = input.scrollHeight + 'px';

        
};

        
previewSvg(input.value);

        
input.oninput = () => {

        
  previewSvg(input.value);

        
  input.style.height = '5px';

        
  input.style.height = input.scrollHeight + 'px';

        
};

        
previewSvg(input.value);