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.
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.
Copy
# Open the example directorycd examples/next-app # or examples/express, examples/hono# Install dependenciesnpm install# Run the test scriptnpm run test:script
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.
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.
try { // Your webhook handling code} catch (error) { console.error('Webhook Error:', error); // During development, log the full error console.debug('Full error details:', { headers: request.headers, body: request.body, error });}
Use TypeScript for better development experience:
Copy
import {type WebhookPayloadV1_0, WebhookPayloadSchemaV1_0 } from '@hookstack/core';// use the built-in schema validator to ensure your event is validconst safeEvent = WebhookPayloadSchemaV1_0.parse(event);await handleWebhook(safeEvent);async function handleWebhook(event: WebhookPayloadV1_0) { // Your event handling code with full type safety}