NPM Package
Use as a CLI tool via npm/npx
# Install globally
npm install -g @metaengine/openapi-react
# Or use with npx
npx @metaengine/openapi-react api.yaml ./src/api
Requirements: Node.js 18+, .NET 8.0+ runtime
NuGet Package
Use programmatically in .NET projects
# Install via dotnet CLI
dotnet add package MetaEngine.TypeScript.OpenApi.React
Requirements: .NET Standard 2.0+
Command Line Usage
Basic Syntax
npx @metaengine/openapi-react <input> <output> [options]
Supports OpenAPI 3.0+ specifications in both JSON and YAML formats.
Quick Examples
# Generate from local file
npx @metaengine/openapi-react api.yaml ./src/api
# Generate from URL
npx @metaengine/openapi-react https://api.example.com/openapi.json ./src/api
# With TanStack Query and Vite
npx @metaengine/openapi-react api.yaml ./src/api \
--tanstack-query \
--documentation \
--base-url-env VITE_API_URL
CLI Options
| Option | Description |
|---|---|
--base-url-env <name> | Environment variable name for base URL [default: REACT_APP_API_BASE_URL] |
--service-suffix <suffix> | Service naming suffix [default: Api] |
--tanstack-query | Enable TanStack Query integration |
--documentation | Generate JSDoc comments |
--options-threshold <n> | Parameter count to use options object [default: 4] |
--include-tags <tags> | Filter by OpenAPI tags (comma-separated, case-insensitive) |
--strict-validation | Enable strict OpenAPI validation |
--verbose | Enable verbose logging |
--help, -h | Show help message |
Programmatic Usage (C#)
Configuration Example
Configuration Example
Framework Support
Generates code compatible with Vite, Next.js, and Create React App. Configure your env var prefix to match your framework.
TanStack Query
Optional integration with useQuery and useMutation hooks for reactive data fetching.
Monorepo Friendly
Configure different environment variables for multiple APIs in the same project.
Options Reference
React Options
WithBaseUrlEnvVar(string)Environment variable name for base URL (default: "REACT_APP_API_BASE_URL")WithServiceSuffix(string)Service suffix (default: "Api")WithTanStackQuery(bool)Generate TanStack Query hooks (default: false)WithMethodNames(Func)Custom method naming ruleWithDocumentation()Enable JSDoc commentsWithOptionsObjectThreshold(int)Parameter count for options object (default: 4)
OpenAPI Filtering
WithStrictValidation()Enable strict OpenAPI validationWithOperationFilter(Func)Filter operations by predicateWithHeaderFilter(Func)Filter header parameters
Naming Transformations
Types(Func)Transform type namesPaths(Func)Transform output pathsFileNames(Func)Transform file names
File Management
CleanDestination()Clean output directory before generationAlwaysOverwrite()Always overwrite existing filesOnlyWhenModelChanged()Update only when model changesOnlyWhenNew()Write only new files, preserve existingCleanDirectories(...)Clean specific subdirectories
Diagnostics
EnableVerboseLogging()Enable detailed logging