Advanced Configuration
For an advanced configuration, you can create avercel.json
file to useRuntimes and other customizations. To view more about the properties you can customize, see theConfiguring Functions andProject config with vercel.json.
If your use case requires that you work asynchronously with the results of a function invocation, you may need to consider a queuing, pooling, orstreaming approach because of how functions are created on Vercel.
Sometimes, you need to place extra code files, such asutils.js
ormy-types.d.ts
, inside the/api
folder. To avoid turning these files into functions, Vercel ignores files with the following characters:
- Files that start with an underscore,
_
- Files that start with
.
- Files that end with
.d.ts
If your file uses any of the above, it willnot be turned into a function.
In order to optimize resources, Vercel uses a process to bundle as many routes as possible into a single Vercel Function.
To provide more control over the bundling process, you can use thefunctions
property in yourvercel.json
file to define the configuration for a route. If a configuration is present, Vercel will bundle functions based on the configuration first. Vercel will then bundle together the remaining routes, optimizing for how many functions are created.
This bundling process is currently only enabled for Next.js, but it will be enabled in other scenarios in the future.
In the following example,app/api/hello/route.ts
will be bundled separately fromapp/api/another/route.ts
since each has a different configuration:
{"$schema":"https://openapi.vercel.sh/vercel.json","functions": {"app/api/hello/route.ts": {"memory":3009,"maxDuration":60 },"app/api/another/route.ts": {"memory":1024,"maxDuration":30 } }}
Was this helpful?