
Val Town Has Free Cloud Functions — Here's How to Run JavaScript in the Cloud Without a Server
What if deploying a function was as easy as saving a file? Val Town gives you instantly deployable JavaScript functions with a built-in editor. What is Val Town? Val Town is a social website to write and deploy TypeScript functions. Every function (called a Val) gets its own URL. No build step, no server, no deploy process. Types of Vals HTTP Handler // Automatically gets a URL: https://username-functionName.web.val.run export default async function ( req : Request ): Promise < Response > { const url = new URL ( req . url ); const name = url . searchParams . get ( " name " ) || " World " ; return Response . json ({ message : `Hello, ${ name } !` }); } Cron Job // Runs on a schedule export default async function () { const res = await fetch ( " https://api.example.com/health " ); if ( ! res . ok ) { // Send alert await email ({ to : " me@example.com " , subject : " API is down! " }); } } Email Handler // Gets its own email address: username.valName@valtown.email export default async fun
Continue reading on Dev.to JavaScript
Opens in a new tab



