Skip to content



You need version 2.x.x or higher to use templates.

What are templates?

With templates, you can easily override/change the generated output of a specific plugin. Let's say you want to use fetch instead of axios, instead of forking the @kubb/swagger-client you can use templates.

In the background, templates will use React/JSX as the template engine. See @kubb/react to find out which intern components and hooks we provide.

How to use templates?

How does it work?

For example, the following code will create a file helloWorld.ts inside the ./src folder(the FileManager will handle the creation of this file).

Next to that, we have an import(see File.Import) that will add an import statement to the generated file.

At this moment the file will only contain the import statement. To add some code we will use File.Source to export a const called helloWorld.

All of this is handled by @kubb/react, see root.render, where we render the template and also provide some extra meta(that will be used by the hooks we provide). As a user of templates you don't need to do anything, this is all handled by theOperationGenerator of the specific plugin you use.

  <File.Import name="axios" path="axios" />
    export const helloWorld = true;
import axios from 'axios'

export const helloWorld = true

Released under the MIT License.