Skip to content

Commit

Permalink
Merge branch 'main' into changeset-release/main
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnvanhulle authored Nov 4, 2024
2 parents c783256 + 03bf791 commit 5940fd2
Showing 1 changed file with 39 additions and 15 deletions.
54 changes: 39 additions & 15 deletions docs/blog/v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,48 @@ Published: 2024-09-01

# Introducing Kubb v3: A New Era of Code Generation

We’re excited to announce the release of Kubb v3, a major update that brings significant improvements, new features, and enhanced flexibility to the Kubb ecosystem. Whether you’re a seasoned user of Kubb or new to the framework, v3 is designed to make your development workflow more efficient, customizable, and future-proof.
In this post, we’ll dive into the key features of Kubb v3, explore what’s new, and show you why this version is a game-changer for developers looking to streamline their TypeScript and API-centric workflows.
We’re excited to announce the release of Kubb v3, a major update that brings significant improvements, new features, and enhanced flexibility to the Kubb ecosystem. V3 is designed to make your development workflow more efficient, customizable, and future-proof.
In this post, we’ll dive into the key features of Kubb v3 and explore what’s new.

## What is Kubb?
For those unfamiliar with Kubb, it’s a flexible framework built to automate code generation in TypeScript projects. Kubb simplifies repetitive tasks like creating API clients, generating type-safe code, and orchestrating file generation processes. By integrating with tools like OpenAPI, Kubb ensures that your code remains aligned with your API specifications, reducing the risk of errors and improving maintainability.
For those unfamiliar with Kubb, it’s a flexible framework built to automate code generation based on Swagger/OpenApi spec file. Kubb simplifies your workflow by creating API clients, generating type-safe code, Zod schema's, React-Query code, ...
By integrating with tools like OpenAPI, Kubb ensures that your code remains aligned with your API specifications, reducing the risk of errors and improving maintainability.
## What’s New in Kubb v3?
Kubb v3 builds on the foundation of previous versions with several key improvements and new features designed to give you more control and flexibility.
1. A New Plugin Architecture
1. An updated Plugin Architecture
One of the most significant changes in Kubb v3 is the overhaul of the plugin architecture which makes the generation faster and by having a progressbar also easier to see what is going on.
| | |
|---------:|:----------|
| Left: v3 | Right: v2 |
One of the most significant changes in Kubb v3 is the overhaul of the plugin architecture. In previous versions, all frameworks and functionalities were bundled together, leading to unnecessary overhead in certain projects. With v3, each framework (React, Tanstack Query, etc.) is now available as its own package.
![React-DevTools](../screenshots/cli-speed.gif)
Next to that, we also improved the usage of Tanstack Query. With v3, each framework (React, Vue, Solid and Svelte) is now available as its own package.
This means you can now pick and choose the exact tools you need, keeping your project lightweight and optimized. For example, if you only need Tanstack Query, you can now install just that package without bringing in unnecessary dependencies.
2. Dropping Support for Tanstack Query v4
To stay up-to-date with the latest advancements, Kubb v3 focuses solely on supporting Tanstack Query v5. We’ve dropped support for Tanstack Query v4, but if your project still depends on it, you can continue using Kubb v2. This shift allows us to take full advantage of the improvements and features introduced in v5.
To stay up-to-date with the latest advancements, Kubb v3 focuses solely on supporting Tanstack Query v5. We’ve dropped support for Tanstack Query v4, but if your project still depends on it, you can continue using Kubb v2.
This shift allows us to take full advantage of the improvements and features introduced in v5.
3. Generators: The Core of Kubb v3
Generators have always been an integral part of Kubb, and in v3, they’re more powerful than ever. Generators allow you to hook into the file generation process and customize or add code dynamically. Each plugin uses generators to handle file creation, and now you can reuse existing generators.
For example, if you’re using @kubb/plugin-client to generate an API client but want to append additional functionality to the generated files, you can either:
> [!TIP]
> In v2 of Kubb we used the name templates.
Generators have always been an integral part of Kubb, and in v3, they’re more powerful than ever.
Generators allow you to hook into the file generation process and customize or add code dynamically.
Each plugin uses generators to handle file creation, and now you can reuse existing generators.
For example, if you’re using `@kubb/plugin-client` to generate an API client but want to append additional functionality to the generated files, you can either:
- Use the footer option to add code.
- Override the default generator for complete customization.
- Override the default generator and add your own logic.
This level of flexibility allows you to tailor Kubb to your project’s exact needs without sacrificing the benefits of automation.
Expand All @@ -63,28 +78,37 @@ We’ve completely revamped the core engine of Kubb to be faster and more effici
5. File Extensions and Compatibility
In the latest version of Node.js, file extensions are now required when importing modules. To accommodate this, Kubb v3 automatically appends .ts extensions to generated files. However, for projects that do not yet use this Node.js configuration, you can remove the extension or switch to .js if needed, ensuring backward compatibility.
In the latest version of Node.js, file extensions are now required when importing modules. To accommodate this, Kubb v3 automatically appends `.ts` extensions to generated files. H
owever, for projects that do not yet use this Node.js configuration, you can remove the extension or switch to .js if needed, ensuring backward compatibility.
6. Beyond OpenAPI: Future-Proofing with New Specification Support
Previously, Kubb was closely tied to Swagger, but with v3, we’ve extended support for OpenAPI v3 and v3.1. More importantly, this change sets the stage for future support of other specifications, making Kubb more adaptable to emerging standards in the API ecosystem.
Previously, Kubb was closely tied to Swagger, but with v3, we’ve extended support for OpenAPI v3 and v3.1.
More importantly, this change sets the stage for future support of other specifications, making Kubb more adaptable to emerging standards in the API ecosystem.
## Migrating to Kubb v3
Check out our detailed [migration guide](/migration-guide) for a step-by-step walkthrough.
## Why You Should Upgrade to Kubb v3
With Kubb v3, you’ll experience a more flexible, modular approach to code generation that can adapt to the unique needs of your project. The enhanced performance, refined generators, and the ability to customize file generation make Kubb v3 a powerful tool in any TypeScript developer’s toolkit.
With Kubb v3, you’ll experience a more flexible, modular approach to code generation that can adapt to the unique needs of your project.
The enhanced performance, refined generators, and the ability to customize file generation make Kubb v3 a powerful tool in any TypeScript developer’s toolkit.
Key Benefits of Upgrading:
- Optimized for modern frameworks: Install only the frameworks and plugins you need.
- Optimized for Tanstack Query v5: Install only the framework you need.
- Support for Suspense
- `Enabled` flag set based on a required field
- Support for Signals
- `paramsType` with option `object` to have an object-oriented generation
- Only generate queryOptions by disabled the query generation
- Seamless API integration: Take advantage of updated support for OpenAPI v3 and v3.1.
- Enhanced customization: Use generators to fine-tune your code and add custom logic.
- Future-proof: Prepare your codebase for new API specifications and the latest JavaScript/TypeScript features.
## Conclusion
Kubb v3 brings a new level of sophistication and flexibility to TypeScript code generation. Whether you’re working on a small project or managing a complex codebase, Kubb v3 empowers you to automate and streamline your development process with ease. With faster performance, better plugin architecture, and the powerful generator system, Kubb v3 is ready to meet the needs of modern developers.
Kubb v3 brings a new level of sophistication and flexibility to TypeScript code generation. Whether you’re working on a small project or managing a complex codebase, Kubb v3 empowers you to automate and streamline your development process with ease.
With faster performance, better plugin architecture, and the powerful generator system.
Ready to get started? Check out the documentation and explore how Kubb v3 can supercharge your project today!
Expand Down

0 comments on commit 5940fd2

Please sign in to comment.