subaya
v1.0.6
Published
A CLI tool for generating boilerplate code for Next.js projects.
Maintainers
Readme
Subaya
A CLI tool for frontend development that automates image optimization, state management, API configuration, and more.
Installation
npm i subayaUsage
Run commands with npx subaya from your project root.
Single-command categories
| Command | Description |
| ------------------------- | ------------------------------------------------- |
| npx subaya route | Generate Next.js route files |
| npx subaya icon | Convert SVG files to React components |
| npx subaya api | Generate API client files (oRPC) |
| npx subaya env | Generate .env template and env type definitions |
| npx subaya localstorage | Generate LocalStorage state utility |
| npx subaya state | Generate global state (Zustand-based) |
| npx subaya supabase | Connect and configure Supabase |
| npx subaya share | Generate SNS sharing utility and hook |
Image subcommands
| Command | Description |
| --------------------------- | --------------------------------------------------------------------- |
| npx subaya image optimize | Optimize images (WebP conversion; optional resize by filename suffix) |
| npx subaya image removebg | Remove background from PNG images |
| npx subaya image resize | Resize specific images |
Configuration
Configuration is optional. Create subaya.config.js in your project root (the directory where you run npx subaya). If the file is missing, defaults are used and a warning is printed.
Location: ./subaya.config.js (resolved from the current working directory)
Format: CommonJS module exporting a default object.
Schema
// subaya.config.js
module.exports = {
image: {
optimize: {
// Optional. Max width (px) for images whose filename ends with _bg, _mbg, _thumb, or _icon.
// Only the keys below are read; values must be numbers.
maxWidth: {
bg: 1920, // e.g. hero_bg.png → resized to max 1920px width
mbg: 800, // e.g. section_mbg.png
thumb: 400, // e.g. photo_thumb.png
icon: 64, // e.g. logo_icon.png
},
},
removebg: {
// Required for `subaya image removebg`. API key for the background-removal service.
removebgApiKey: process.env.REMOVEBG_API_KEY || null,
},
},
api: {
// Used by `subaya api` (oRPC) to fetch schema from your API.
baseUrl: process.env.API_BASE_URL || null,
consistentTypeImports: true, // for eslint
infiniteParams: ["latestDate", "earliestDate"], // for react infinity query params
},
}Config reference
| Field | Used by | Description |
| ------------------------------- | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| image.optimize.maxWidth | subaya image optimize | When an image filename ends with _bg, _mbg, _thumb, or _icon, the image is resized so its width does not exceed the corresponding value (in pixels). Omitted keys are ignored. Percent-based resize (e.g. _50%) is handled automatically and does not use this config. |
| image.removebg.removebgApiKey | subaya image removebg | API key for the background-removal service. If not set, the command will warn and skip API-based removal. |
| api.baseUrl | subaya api | Base URL of your API. Used by the oRPC generator to fetch the schema. If not set, the command will warn. |
Requirements
- Node.js (see your project’s supported version).
- Optional:
@imgly/background-removal-nodeis a peer dependency forsubaya image removebg. Install it in your project if you use background removal.
License
ISC
