App Functions
Serverless TypeScript functions that run on AppEngine. Use them for external API calls, heavy processing, or anything that shouldn't run in the browser.
// api/my-data.function.ts
export default async function handler({ request }) {
const response = await fetch("https://external-api.com/data");
const data = await response.json();
return new Response(JSON.stringify(data));
}
File naming: api/*.function.ts โ becomes an endpoint
Limits: 256MB RAM, 120 second timeout
Calling from Frontend
import { useAppFunction } from "@dynatrace-sdk/react-hooks";
const { data, error, isLoading } = useAppFunction({
id: "my-data", // matches filename without .function.ts
data: { filter: "production" }
});
โ ๏ธ External API calls from the frontend are blocked by CSP. Use app functions as a proxy.
Server-Side Filtering
// api/filtered-hosts.function.ts
export default async function handler({ request }) {
const body = await request.json();
const { data } = await queryDql(
`fetch dt.entity.host | filter contains(entity.name, "${body.filter}")`
);
return new Response(JSON.stringify(data));
}
๐ง Quick Check
Where do app functions (serverless) run?
What's Next
Module 9 โ Intents: navigate between apps and pass context.