Rendering API

#generateStatic()

Generates a static generated site (SSG)

function generateStatic(options: GenerateStaticOptions): Promise<{
    files: any[];
    elapsed: number;
}>;
  • options site generation options

#GenerateStaticOptions

Options for generating static sites

type GenerateStaticOptions = {
    entryFile?: string[];
    entryMain?: string[];
    entryHtml?: string[];
    entryUrls?: string[];
    ext?: string;
    pretty?: boolean;
    outDir?: string;
    baseUrl?: string;
    verbose?: boolean;
    cssUrl?: string;
};

#baseUrl

The base URL used to qualify in-page URLs to an external full URL

baseUrl?: string;

#cssUrl

Name of the CSS styles file

cssUrl?: string;

#entryFile

The entry .js file (as an array, first found used)

entryFile?: string[];

#entryHtml

The HTML file to use as template for generated files (as an array, first found used)

entryHtml?: string[];

#entryMain

The name of the entry point function in the entryFile (as an array, first found used)

entryMain?: string[];

#entryUrls

The URL's to render (will also recursively render all linked URLs)

entryUrls?: string[];

#ext

The extension to append to all generated files (including the period)

ext?: string;

#outDir

The output directory to write generated files

outDir?: string;

#pretty

Prettify the generated HTML

pretty?: boolean;

#verbose

Verbose output

verbose?: boolean;

#SSRResult

The results of an SSRWorker/SSRWorkerThread render operation.

In addition to the content property, this object includes any properties from the ssr property of the route object to which the URL was matched. This can be used to return additional information such as HTTP status codes from the rendering process.

type SSRResult = {
    content: string;
};

#content

The rendered HTML

content: string;

#SSRWorker Class

Implements page rendering for SSG and/or SSR

class SSRWorker {
    init(options: {
        entryFile: string;
        entryMain: string;
        entryHtml: string;
        cssUrl?: string;
    }): Promise<void>;
    stop(): Promise<void>;
    getStyles(): Promise<string>;
    render(url: string, options: any): SSRResult;
}

#getStyles()

Gets the declared CSS styles

getStyles(): Promise<string>;

#init()

Initializes the SSR worker

init(options: {
    entryFile: string;
    entryMain: string;
    entryHtml: string;
    cssUrl?: string;
}): Promise<void>;
  • options Options

  • options.entryFile The main entry .js file

  • options.entryMain The name of the main function in the entry file

  • options.entryHtml An HTML string into which mounted components will be written

  • options.cssUrl A URL to use in-place of directly inserting CSS declarations

#render()

Renders a page

render(url: string, options: any): SSRResult;
  • url URL of the page to render

  • options Additional options to be made available via coenv

#stop()

Stops the worker.

stop(): Promise<void>;

#SSRWorkerThread Class

Runs an SSRWorker in a Node worker thread for application isolation

class SSRWorkerThread {
    init(options: {
        entryFile: string;
        entryMain: string;
        entryHtml: string;
        cssUrl?: string;
    }): Promise<void>;
    render(url: string): SSRResult;
    getStyles(): Promise<string>;
    stop(): Promise<any>;
}

#getStyles()

Gets the declared CSS styles

getStyles(): Promise<string>;

#init()

Initializes the SSR worker

init(options: {
    entryFile: string;
    entryMain: string;
    entryHtml: string;
    cssUrl?: string;
}): Promise<void>;
  • options Options

  • options.entryFile The main entry .js file

  • options.entryMain The name of the main function in the entry file

  • options.entryHtml An HTML string into which mounted components will be written

  • options.cssUrl A URL to use in-place of directly inserting CSS declarations

#render()

Renders a page

render(url: string): SSRResult;
  • url URL of the page to render

#stop()

Stops the worker.

stop(): Promise<any>;

#viteGenerateStatic()

Vite Plugin to generate static sites.

function viteGenerateStatic(options: GenerateStaticOptions): {
    name: string;
    configResolved: (config: any) => void;
    buildStart: () => Promise<void>;
    closeBundle: () => Promise<void>;
};
  • options options used for static page generation