It’s easier to set up a NextJS project to set up API routes than to use the native building blocks of vercel functions. There isn’t a template for simple vercel functions usage in vercel init. I couldn’t find information about es module support or how to build the code (TS) to be correctly supported on the runtime. And it’ts hard to find information because it’s mixed with NextJS stuff
Hey @benjavicente. Someone else had a similar problem with TS functions recently, but with a Hono project. The solution was to set the tsconfig.json for ESM and make sure it’s not excluded by .vercelignore. Can you give this a try and let me know if it works for you?
Run npm install vercel --save-dev to include the CLI as a dev dependency
Add a tsconfig.json with module: ESNext and moduleResolution: node as compilerOptions
Add /api/index.ts with export function GET() and return your desired response. (I copied the Other Frameworks example from the Vercel Functions Quickstart page)
Include a vercel.json file to redirect from the home path to /api