You are currently offline, serving cached version

Asynchronous Data Resolving

You can have promises in your data to resolve data from URLS, from your database, ….

If what you want is to avoid blocking the main thread when generating the document, it is best to use Web Workers in the browser or Worker Threads in Node.

Note that the only step running asynchronously is the resolving of your data. The compilation (parsing of your template to parse position and validity of each tags), and the rendering (which uses the compiled version + the resolved data) will still be fully synchronous.

// Compile your document
const doc = new Docxtemplater(zip, options);
    user: new Promise((resolve) => {
        // You could also resolve your data from an HTTP request, an async call
        // to your database, a call to an external API, ...
        setTimeout(() => resolve("John"), 1000);
}).then(function () {
    const buf = doc.getZip().generate({ type: "nodebuffer" });
        path.resolve(__dirname, "output.docx"),