zendfi init
Adds ZendFi to your current project with automatic framework detection, SDK installation, and file generation.Options
| Flag | Description | Default |
|---|---|---|
--framework <name> | Override framework detection | Auto-detected |
--skip-install | Skip @zendfi/sdk installation | false |
-y, --yes | Skip all confirmation prompts | false |
What It Does
Detect your framework
The CLI inspects your
It also detects your package manager from lock files (bun.lockb, pnpm-lock.yaml, yarn.lock, or npm) and checks for TypeScript support.
package.json and project structure to identify your framework:| Framework | Detection Method |
|---|---|
| Next.js (App Router) | next dependency + app/ directory + version >= 13 |
| Next.js (Pages Router) | next dependency without App Router |
| Express.js | express dependency |
| React | react dependency without next |
| Vue.js | vue dependency |
| SvelteKit | @sveltejs/kit dependency |
| Node.js | Fallback for any package.json project |
Install the SDK
Runs the appropriate install command for your package manager:Skip this step with
--skip-install if you want to handle installation yourself.Generate project files
Creates framework-specific files tailored to your project:Next.js (App Router):
Next.js (Pages Router):
Express.js:
Other frameworks:
Existing files are never overwritten. If a file already exists, the CLI skips it and lets you know.
| File | Purpose |
|---|---|
lib/zendfi.ts | Pre-configured ZendFi client instance |
app/api/webhooks/zendfi/route.ts | Webhook handler route |
.env.local | Environment variables template |
| File | Purpose |
|---|---|
lib/zendfi.ts | Pre-configured ZendFi client instance |
pages/api/webhooks/zendfi.ts | Webhook handler API route |
.env.local | Environment variables template |
| File | Purpose |
|---|---|
src/lib/zendfi.ts | Pre-configured ZendFi client instance |
src/routes/webhooks.ts | Webhook handler route |
.env | Environment variables template |
| File | Purpose |
|---|---|
src/lib/zendfi.ts | Pre-configured ZendFi client instance |
src/webhooks.ts | Webhook handler |
.env | Environment variables template |
Example
Non-Interactive Mode
For CI/CD pipelines or scripts, use the-y flag to skip all prompts:
create-zendfi-app
Create a complete ZendFi project from a pre-built template. This is a standalone package that wraps thecreate command with an interactive wizard.
Options
| Flag | Description | Default |
|---|---|---|
--template <name> | Template to use | Interactive selection |
--env <environment> | Environment (development or production) | development |
-y, --yes | Skip confirmation prompts | false |
--skip-install | Skip dependency installation | false |
--skip-git | Skip git initialization | false |
Templates
nextjs-ecommerce -- Next.js E-commerce
nextjs-ecommerce -- Next.js E-commerce
A full-featured online store built with Next.js 14 App Router.Features:
- Product catalog page
- Shopping cart
- Checkout with ZendFi payment integration
- Order confirmation page
- Webhook handler for payment events
- Embedded admin dashboard
nextjs-saas -- Next.js SaaS
nextjs-saas -- Next.js SaaS
A subscription-based SaaS application with Next.js 14 App Router.Features:
- Subscription plans page
- User authentication
- Customer portal
- Webhook handler for subscription events
- Usage tracking
- Payment history
express-api -- Express API
express-api -- Express API
A backend API server with pre-configured payment endpoints.Features:
- Payment creation endpoint
- Webhook handler
- CORS configuration
- Environment variable setup
- TypeScript support
Scaffolding Flow
Template Variables
Templates support these placeholder variables that are replaced during scaffolding:| Variable | Replaced With |
|---|---|
{{PROJECT_NAME}} | Your chosen project name |
{{API_KEY}} | Your API key (if provided during setup) |
{{WEBHOOK_SECRET}} | Your webhook secret (if provided) |
{{ENVIRONMENT}} | Selected environment (development or production) |
Example
Package Manager Detection
Bothzendfi init and create-zendfi-app automatically detect your preferred package manager:
| Lock File | Package Manager |
|---|---|
bun.lockb | bun |
pnpm-lock.yaml | pnpm |
yarn.lock | yarn |
| (none) | npm |