Prerequisites
Before installing the SDK, ensure you have:Node.js or Runtime
- Node.js 16+ (for Node.js environments)
- Bun, Deno, or any modern JavaScript runtime
TypeScript (Optional)
- TypeScript 5.0+ recommended for the best experience
- Works with JavaScript projects too
You’ll need a Paystack account and API keys. Get yours at paystack.com
Package Installation
Install the SDK using your preferred package manager:Install Peer Dependencies
The SDK requires Zod for runtime validation. Install it if you haven’t already:Environment Setup
Get Your API Keys
Paystack provides two types of secret keys:- Test keys (
sk_test_...) - For development and testing - Live keys (
sk_live_...) - For production use
Configure Environment Variables
Create a.env file in your project root:
.env
Environment-Specific Configuration
For different environments, use separate environment variables:.env.example
TypeScript Configuration
Recommended tsconfig.json
For optimal TypeScript support, configure yourtsconfig.json:
tsconfig.json
The SDK uses ES modules. Ensure your project is configured to support them.
Type Definitions
The SDK includes full TypeScript definitions. Import types as needed:types.ts
Framework-Specific Setup
Node.js with Express
index.ts
Next.js (App Router)
No additional configuration needed. Use environment variables in.env.local:
.env.local
app/api/payment/route.ts
Bun
Bun has built-in environment variable support:index.ts
Cloudflare Workers
Use Wrangler secrets for environment variables:worker.ts
Deno
mod.ts
Verify Installation
Create a simple test file to verify your setup:test.ts
Common Issues
Module not found errors
Module not found errors
Ensure you’ve installed both
@efobi/paystack and zod:Invalid secret key error
Invalid secret key error
The SDK validates that your key starts with
sk_test_ or sk_live_. Check your environment variables:TypeScript errors
TypeScript errors
Ensure you’re using TypeScript 5.0 or higher:
ESM import issues
ESM import issues
If you’re using CommonJS, ensure your Or use
package.json has:.mjs file extensions.Next Steps
Now that you have the SDK installed, you’re ready to build your first integration:Quick Start Guide
Learn how to initialize transactions and verify payments

