Development
Test and develop your webhook handlers locally
Local Development
When developing webhook handlers, you may want to test them before deploying to production. Hookstack provides several tools to make local testing easy and reliable.
Using the Test Scripts
The Hookstack SDK includes example applications and test scripts to help you get started. These scripts generate properly signed payloads and send them to your local webhook handler.
This will:
- Generate a sample webhook payload
- Sign it with your provided test secret
- Send it to your local webhook endpoint (default:
http://localhost:3000/api/webhooks
)
The test script is particularly useful for initial integration testing as it ensures your signature verification is working correctly.
Example Applications
The SDK includes several example applications that demonstrate proper webhook handling:
Testing with Real Events
Dashboard Replay
Once you’ve received webhooks in production, you can replay them to your development environment:
- Log into your Hookstack Dashboard
- Navigate to the Destinations or Routes section
- Find the webhook event you want to replay
- Click the “Replay” icon to have HookStack re-send the event to your development environment
This allows you to:
- Test your handler with real production data
- Debug issues with specific webhook payloads
- Verify your handler works across different event types
Make sure your development environment is accessible from the internet when using the replay feature. Tools like ngrok or cloudflared can help expose your local server.
Best Practices
Local Development Setup
- Use environment variables for configuration:
- Set up proper error handling:
- Use TypeScript for better development experience: