Introduction
Hi 👋🏽 and welcome to Kubb!
My name is Stijn Van Hulle, the creator of Kubb and I'm super excited to have you here! Let me give you a quick introduction to Kubb and what it can do for you.
Kubb is a library and toolkit that converts your Swagger/OpenAPI specification to one of the generated client libraries(TypeScript, React-Query, Zod, Zodios, Faker.js and Axios).
Imagine that your backend team is writing an API in Java/Kotlin, how do you connect your frontend to their system without the need of communicating on every API change. This is not a new problem and has already been resolved with the use of a Swagger/OpenAPI specification and a code generator.
The problem is that most of them are good at one thing: generating TypeScript types or generating React-Query hooks. Kubb is trying to resolve that with a plugin system where we already provide you with some generation plugins but also giving you the possibilty to create your own generation plugin without the need of forking the full project.
Motivation
Swagger/OpenAPI has been used a lot as a contract between frontend and backend teams, this was the same for the last couple of projects I did. Every project is different so it always came down in choosing one of the provided code generators or the default one of Swagger. But that wasn't enough for my needs 🙁.
Main features ✨:
- Every generated client(React-Query, MSW, Zod, ...) is contained in it's own package.
- Clean code that follows the examples of the client(no extra un-needed boilerplate code).
- Out-of-box TypeScript (with JSDoc) support.
- Open-source first.
- Plugins system based on Rollup, esbuild,
- CLI support.
Installation 1.14.9
You can install Kubb via NPM.
bun add @kubb/cli @kubb/core
bun add @kubb/cli @kubb/core
pnpm add @kubb/cli @kubb/core
pnpm add @kubb/cli @kubb/core
npm install @kubb/cli @kubb/core
npm install @kubb/cli @kubb/core
yarn add @kubb/cli @kubb/core
yarn add @kubb/cli @kubb/core
See Installation
Configuration File
Kubb uses Cosmiconfig for the configuration file support. This means you can configure Kubb via (in order of precedence):
- A "kubb" key in your package.json file.
- A
.kubbrc
file written in JSON or YAML. - A
.kubbrc.json
file. - A
.kubbrc.js
,.kubbrc.cjs
,kubb.config.js
, orkubb.config.cjs
file that exports an object using module.exports. - A
.kubbrc.ts
orkubb.config.ts
file that exports an object using export default.
TIP
You can also use configs/kubb.config.ts
or .config/kubb.config.ts
instead of kubb.config.ts
in the root of your project.
See kubb.config.js on how to configure Kubb.