HyperFetch CLI
CLI is a tool that allows to automate some of the hyper-fetch features. It's a great way to get started with HyperFetch and to automate your workflow by generating a typed SDK from your API schema.
npx @hyper-fetch/cli@latest
This basic command will open the wizard to guide you through the setup process.
- Generate code from your OpenAPI or Swagger schema.
- Configure once with an
api.jsonfile that decides where generated files go. - Automate your workflow by regenerating the SDK in scripts and CI.
Usage
You can use it in two ways - by going through wizard or passing individual arguments.
Wizard
To use the wizard, run the following command:
npx @hyper-fetch/cli@latest
It lets you pick a command (init or generate) and asks for every value it needs.
Custom arguments
You can also pass individual arguments to the command. Which is useful for the scripts.
npx @hyper-fetch/cli@latest {command}
Example:
npx @hyper-fetch/cli@latest generate
Auto-Initialization
The CLI automatically initializes your project when needed. If you run any command (like generate) on a project that
hasn't been set up yet (no api.json config file), the CLI will automatically run the init flow first, then proceed
to your original command.
This means you can jump straight to generating code without running init manually:
# This "just works" — auto-inits if api.json is missing, then generates
npx @hyper-fetch/cli@latest generate --url https://api.example.com/openapi.json
The auto-init creates:
- An
api.jsonconfiguration file in the working directory (--cwd) - A
src/apidirectory for generated code - Default path aliases for api, hooks, components, and lib directories
If you prefer to configure things manually first, you can still run init separately. The auto-init only triggers
when api.json is not found.
More
We will be covering individual commands in the next sections.
You've learned how to use the CLI in HyperFetch!
- You can use the wizard to guide you through the setup process.
- You can pass individual arguments to the command for more control.