Standalone scripts run independently to perform specific tasks without the need for external intervention. They are useful when you need complete control over execution and state. By using standalone functions, you can serve dynamic content, implement custom logic, and manipulate requests and responses directly at the edge. This approach eliminates the need for an origin server in many scenarios, allowing you to build powerful, low-latency applications.Documentation Index
Fetch the complete documentation index at: https://docs.bunny.net/llms.txt
Use this file to discover all available pages before exploring further.
Use cases
- REST APIs and microservices — Handle client requests and return responses directly from the edge
- Dynamic UIs and landing pages — Generate and serve content based on user interactions or geolocation
- AI-powered endpoints — Process images, run chat completions, or generate embeddings
- Backend functions for static frontends — Power contact forms, webhooks, and data submissions
- External API calls — Send emails, transform data, or integrate with third-party services
Benefits
By executing directly at the network’s edge, standalone scripts reduce latency significantly, enabling faster data processing and response times. They are inherently capable of handling multiple requests simultaneously without straining resources, facilitating smooth scalability as user demands increase.The serve function
The serve function starts an HTTP server that listens for incoming requests and handles them using the provided handler function.
Function signature
Handler
The handler function receives a standard Request object and must return a Response orPromise<Response>.