CLI
CLI is a tool that allows to automate some of the hyper-fetch features. It's a great way to get started with Hyper-Fetch and to automate your workflow by generating code and adding sdks.
npx @hyper-fetch/cli@latest
This basic command will open the wizard to guide you through the setup process.
- Generate code from your api schema.
- Add sdks to your project from the remote locations.
- Automate your workflow by generating code and adding sdks.
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 will guide you through the process of generating the client, requests and data models.
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 your project root - 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 Hyper-fetch!
- You can use the wizard to guide you through the setup process.
- You can pass individual arguments to the command for more control.
