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

#

React Library

Use @myriaddreamin/typst.react.


        
import { TypstDocument } from '@myriaddreamin/typst.react';

        


        
export const App = (artifact: Uint8Array) => {

        
return (

        
  <div>

        
  <h1>Demo: Embed Your Typst Document in React</h1>

        
  <TypstDocument fill="#343541" artifact={artifact} />

        
  </div>

        
);

        
};

        
import { TypstDocument } from '@myriaddreamin/typst.react';

        


        
export const App = (artifact: Uint8Array) => {

        
return (

        
  <div>

        
  <h1>Demo: Embed Your Typst Document in React</h1>

        
  <TypstDocument fill="#343541" artifact={artifact} />

        
  </div>

        
);

        
};

#

fill property

Fill document with color.


        
<TypstDocument fill="#343541"/>

        
<TypstDocument fill="#343541"/>

Note: Current typst.ts doesn't support a transparent background color in some browsers.

#

artifact property

Render the document with artifact from precompiler.


        
<TypstDocument artifact={artifact}/>

        
<TypstDocument artifact={artifact}/>

The artifact can be only in Vector Format to this time.

To get artifact data, please refer to Command Line Interface or All-in-one Node.js Library.

#

Set renderer initialization option for TypstDocument

Retrieve a typst.InitOptions for initializating the renderer for TypstDocument


        
TypstDocument.setWasmModuleInitOptions({

        
  getModule: () =>

        
    'http://localhost:20810/typst_ts_renderer_bg.wasm',

        
});

        
TypstDocument.setWasmModuleInitOptions({

        
  getModule: () =>

        
    'http://localhost:20810/typst_ts_renderer_bg.wasm',

        
});

The default value is:


        
{

        
  beforeBuild: [],

        
  getModule: () => '/node_modules/@myriaddreamin/typst-ts-renderer/pkg/typst_ts_renderer_bg.wasm',

        
}

        
{

        
  beforeBuild: [],

        
  getModule: () => '/node_modules/@myriaddreamin/typst-ts-renderer/pkg/typst_ts_renderer_bg.wasm',

        
}

#

Example: show document

See typst.react demo for more details.