App Development

Deployment

Learn how to deploy your app and how the deployment process works.

Deploying your app is a streamlined process that allows you to run your code.

When you deploy your app, it runs in a serverless environment. This means you don’t have to manage any servers or infrastructure. The platform takes care of scaling, availability, and performance, allowing you to focus solely on your code.

Once deployed, your app is accessible via a unique URL in the format:

https://<app-id>.onmaven.app

Routing to handleRequest

All requests to your app’s URL are routed directly to the handleRequest method defined in your src/index.ts file. This method is responsible for handling all incoming HTTP requests and returning appropriate responses.

Example

Here is a basic example of an src/index.ts file with a handleRequest method:

1export default {
2 async handleRequest({request, ...rest}) {
3 const url = new URL(request.url)
4 if (url.pathname === '/hello') {
5 return new Response('Hello, world!')
6 } else if (url.pathname === '/data') {
7 const data = await request.json()
8 return new Response(JSON.stringify({message: 'Data received', data}), {
9 headers: {'Content-Type': 'application/json'},
10 })
11 } else {
12 return new Response('Not Found', {status: 404})
13 }
14 },
15}