Next.js Integration
Run reliable scheduled tasks on Next.js with webhook-based cron jobs. Perfect for serverless applications with built-in signature verification and monitoring.Overview
Schedo integrates seamlessly with Next.js through webhook-based scheduling. Instead of traditional cron jobs that require persistent processes, Schedo sends HTTP requests to your Next.js API routes at scheduled times.Key Benefits
- Serverless-first: Works perfectly with Next.js serverless functions
- No infrastructure: No need for external cron services or GitHub Actions
- Secure: Built-in cryptographic signature verification
- Monitored: Comprehensive webhook delivery tracking with Schedo.dev dashboard
- Simple: Just one API endpoint to get started
- Full visibility: Track execution times, success rates, and error details
Quick Start
1. Install the SDK
2. Create an API Route
Create a webhook endpoint in your Next.js application:3. Set Environment Variables
Add your Schedo signature key to your environment variables:.env.local
Get your signature key from the Schedo Dashboard under Settings > API Keys.
4. Deploy Your Application
Deploy your Next.js application to your preferred hosting platform:5. Create a Webhook Job
In the Schedo dashboard:- Click “Create Webhook Job”
- Enter your endpoint URL:
https://your-app.com/api/cron - Set your schedule (e.g.,
0 9 * * *for daily at 9 AM) - Click “Create”
Advanced Configuration
Custom Headers
Add custom headers to your webhook requests:Request Payload
Customize the payload sent to your endpoint:Error Handling
Implement robust error handling in your API route:Use Cases
Daily Reports
Database Cleanup
API Synchronization
Deployment Platforms
Schedo webhooks work with any hosting platform that supports Next.js API routes. For optimal performance and reliability, we recommend Sherpa.sh - our preferred Next.js hosting partner with container-first architecture and no function timeouts. Here are configuration examples for popular platforms:Serverless Platforms
For serverless deployments, configure function timeouts appropriately:Platform Configuration
Container Platforms
For containerized deployments:Dockerfile
Platform-Specific Notes
- Serverless Functions: Most platforms limit execution time (typically 10-60 seconds)
- Container Deployments: No execution time limits, better for long-running tasks
- Static Hosting: Ensure API routes are properly configured and deployed
Recommended: Sherpa.sh offers the best experience for Schedo.dev integration with container-based deployments, no timeout limits, and enhanced monitoring. Schedo.dev actively develops new features with Sherpa.sh compatibility first. Learn more about Sherpa.sh integration.
Security Best Practices
Environment Variables
Always store sensitive data in environment variables:Signature Verification
Always verify webhook signatures:Rate Limiting
Implement rate limiting for additional security:IP Allowlisting
For enhanced security, you can restrict your cron endpoints to only accept requests from Schedo.dev servers. This prevents unauthorized access to your webhook endpoints.IP allowlisting is available as an enterprise feature. Contact our support team at support@schedo.dev to enable IP allowlisting for your account and receive the current list of Schedo.dev IP addresses.
- Additional Security Layer: Prevents direct access to your webhook endpoints
- Compliance: Meets security requirements for sensitive applications
- Audit Trail: Clear logging of blocked unauthorized requests
- Peace of Mind: Ensures only Schedo.dev can trigger your scheduled tasks
Monitoring and Debugging
Schedo.dev Dashboard Monitoring
Schedo.dev provides comprehensive monitoring and visibility for your Next.js cron jobs directly in the dashboard:- Execution History: View all webhook calls with timestamps and response codes
- Success/Failure Rates: Track job reliability over time
- Response Times: Monitor your endpoint performance
- Error Details: See detailed error messages and stack traces
- Retry Attempts: Track failed requests and retry patterns
- Payload Inspection: View request and response data for debugging
- HTTP status codes from your Next.js endpoint
- Response times and payload sizes
- Error messages and failure reasons
- Execution trends and patterns
Application-Level Logging
Implement comprehensive logging in your Next.js application:Schedo.dev Monitoring & Visibility
Schedo.dev provides comprehensive monitoring and visibility for your Next.js cron jobs directly in the dashboard. This gives you complete insight into your webhook executions without needing to implement custom monitoring solutions.Dashboard Features
Real-time Monitoring- Live webhook execution status
- Success/failure rates and trends
- Average response times and performance metrics
- Active job status and next scheduled execution times
- Complete log of all webhook calls with timestamps
- HTTP status codes and response details
- Request and response payload inspection
- Error messages and stack traces for failed executions
- Response time trends over different time periods
- Success rate percentages and reliability metrics
- Retry attempt tracking and patterns
- Webhook delivery success rates
- Detailed error messages from your Next.js endpoints
- Failed request retry attempts and outcomes
- Webhook timeout and connection error tracking
Troubleshooting
Common Issues
Signature Verification Fails
Function Timeout
Memory Limits
Debug Mode
Enable debug logging in development:Migration Guide
From Platform-Specific Cron
If you’re migrating from platform-specific cron solutions:From GitHub Actions
Replace GitHub Actions cron with Schedo webhooks:FAQ
Do I need to keep a server running for cron jobs?
Do I need to keep a server running for cron jobs?
No! That’s the beauty of webhook-based scheduling. Your Next.js functions only run when Schedo triggers them, making it perfect for serverless architectures.
How secure are the webhook requests?
How secure are the webhook requests?
Very secure. Every request includes a cryptographic signature that you must verify. This ensures only legitimate Schedo requests can trigger your endpoints.
Can I use this with Next.js Edge Functions?
Can I use this with Next.js Edge Functions?
Yes! The webhook approach works with both Node.js runtime and Edge Runtime functions in Next.js.
What about Next.js function execution limits?
What about Next.js function execution limits?
Most serverless platforms have execution time limits (typically 10-60 seconds). For longer tasks, consider breaking them into smaller chunks or using a queue system.
How do I handle failures and retries?
How do I handle failures and retries?
Return appropriate HTTP status codes from your endpoint. Schedo will automatically retry failed requests based on your retry configuration.
Can I schedule multiple different tasks?
Can I schedule multiple different tasks?
Yes! You can create multiple webhook jobs pointing to different endpoints, or use a single endpoint with custom payload data to determine which task to run.