Installation
Get started with ByteKit by installing it in your project. ByteKit works with Node.js 18+ and all modern browsers.Package installation
Install ByteKit using your preferred package manager:ByteKit has zero dependencies and uses native
fetch for HTTP operations, keeping your bundle size minimal.Requirements
Node.js version
ByteKit requires Node.js 18 or higher. This is because ByteKit uses nativefetch which was introduced in Node.js 18.
Browser support
ByteKit works in all modern browsers that support:- Native
fetchAPI - ES2020+ features
- ESM modules
- Chrome 90+
- Firefox 88+
- Safari 14.1+
- Edge 90+
TypeScript configuration
For the best experience with TypeScript projects, configure yourtsconfig.json with these recommended settings:
tsconfig.json
Key settings explained
target: "ES2020"- ByteKit uses modern JavaScript featuresmodule: "ESNext"- ByteKit is 100% ESMmoduleResolution: "bundler"- Works with Vite, webpack, etc.strict: true- Enables all strict type checking (recommended)
Verification
Verify your installation by creating a simple test file:If you’re using a bundler like Vite, webpack, or Rollup, no additional configuration is needed. ByteKit works out of the box with all modern bundlers.
Global CLI installation (optional)
ByteKit includes a CLI tool for generating TypeScript types from Swagger/OpenAPI specs:Import strategies
ByteKit supports multiple import strategies to optimize your bundle size:Default imports (convenience)
Import everything from the main package:Modular imports (tree-shaking)
Import specific modules to reduce bundle size:Troubleshooting
Module not found errors
If you see “Cannot find module ‘bytekit’” errors:- Ensure you’ve installed the package:
npm install bytekit - Clear your package manager cache:
- npm:
npm cache clean --force - yarn:
yarn cache clean - pnpm:
pnpm store prune
- npm:
- Delete
node_modulesand reinstall:rm -rf node_modules && npm install
TypeScript errors
If TypeScript can’t find types:- Ensure
moduleResolutionis set to"bundler"or"node" - Make sure
skipLibCheckis set totrue - Try restarting your TypeScript server in your editor
Fetch is not defined
If you see “fetch is not defined” in Node.js:- Upgrade to Node.js 18 or higher
- Or use a fetch polyfill for older versions
Next steps
Quick start guide
Now that you have ByteKit installed, follow our quick start guide to learn the basics