Compute / your logic, managed
Custom Functions
Make your application do something unique.
The idea
Put your business rules in one focused function.
Imagine building an application that calculates shipping prices. The price depends on weight, distance, delivery speed, and discounts.
That is business logic specific to your application. A Custom Function lets you run it without managing a traditional application server.
Application blip
Shipping Calculator
Behind the scenes
A small function turns an action into an answer.
- User action
- Custom Function
- Business logic
- Result
The app sends validated inputs to a function. It applies your business rules and returns a structured result for the rest of the application to use.
What could you build?
- Pricing engines
- Payment workflows
- Third-party integrations
- Data transformations
- Custom automation
Implementation notes
- Keep functions focused on one business rule.
- Validate inputs before calculating or calling other services.
- Return structured results the rest of your app can use.
Implementing it
With a coding agent
Ask your agent to add custom logic
Copy this prompt, fill in the bracketed details, and paste it into your coding agent. It describes the goal, the business rule, and the guardrails.
Bracketed text marks details only you can fill in. 896 / 6,000 characters.
Good foundation · 65/100
Traditional SDK / API
Calculate shipping with a custom function
const destinationFees = { "new-york": 6, chicago: 4, "los-angeles": 7.5 }
const deliveryFees = { standard: 0, express: 4.5, overnight: 9 }
export function calculateShipping(input: {
weightKg: number
destination: keyof typeof destinationFees
delivery: keyof typeof deliveryFees
discountCode?: string
}) {
const subtotal = 6.5 + input.weightKg * 1.5 + destinationFees[input.destination] + deliveryFees[input.delivery]
const discount = input.discountCode?.trim().toUpperCase() === "WELCOME10" ? subtotal * 0.1 : 0
return Math.round((subtotal - discount) * 100) / 100
}Key takeaway
Custom Functions let you implement the logic that makes your application different from everyone else’s.
Next primitive
Document Database