Skip to main content

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:
  1. Click “Create Webhook Job”
  2. Enter your endpoint URL: https://your-app.com/api/cron
  3. Set your schedule (e.g., 0 9 * * * for daily at 9 AM)
  4. 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.
Once enabled, you can implement IP filtering in your Next.js application:
Benefits of IP allowlisting:
  • 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
The dashboard automatically captures and displays:
  • 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
Detailed Execution History
  • 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
Performance Analytics
  • Response time trends over different time periods
  • Success rate percentages and reliability metrics
  • Retry attempt tracking and patterns
  • Webhook delivery success rates
Error Tracking & Debugging
  • 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

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.
Very secure. Every request includes a cryptographic signature that you must verify. This ensures only legitimate Schedo requests can trigger your endpoints.
Yes! The webhook approach works with both Node.js runtime and Edge Runtime functions in Next.js.
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.
Return appropriate HTTP status codes from your endpoint. Schedo will automatically retry failed requests based on your retry configuration.
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.

Next Steps