What are Lambda Functions?
Lambda functions allow you to execute JavaScript or TypeScript inside of your Xano function stacks. You may prefer to do this if you are porting old workflows to Xano and already have the code written, or maybe you just prefer to write code instead of using the function stack. You can also use Lambda functions to leverage custom NPM packages.How do I write Lambda functions in Xano?
Special Variables
Lambdas have the ability to reference all the available data just like normal function stack statements. All special variables are prefixed with a$ symbol.
- Xano variables are accessible through the
$varspecial variable. To access a Xano variable named title, you would reference it as$var.title. - Xano inputs are accessible through the
$inputspecial variable. To access a Xano input named score, you would reference it as$input.score. - Xano environment variables are accessible through the
$envspecial variable. To access a Xano environment variable named ip, you would reference it as$env.ip. - The authenticated user details are accessible through the
$authspecial variable. The most common members of this variable include$auth.idand$auth.extras. If there is no authenticated user, then$auth.idwill evaluate as 0.
Context Variables
Depending on how you use a Lambda, you may have support to access some additional variables, known as context variables. These follow the same naming convention as special variables by using a$ prefix. The most common context variables will be $this, $index, $parent, and $result. The meaning of these variables are best described within the examples of the higher order filters.
Using the Lambda AI Assistant
1
Give the assistant context by running your function stack first.
If you don’t do this, you can still use the AI assistant, but it will make certain inferences that may not be correct.
2
Look for the 'AI Assistant' button and click it to enable the assistant.

3
Ask the assistant for help as needed.
In this example, we’re asking the assistant to write a function that imports the Decamelize library and applies it to our ‘test’ input.

4
Choose how to proceed with the assistant's suggestions.
You can click
to add the suggestions to the Lambda function code, or you can copy it manually and place it as needed.Be sure to rate the assistant’s suggestion(s) using the 👍 and 👎 buttons. We’ll use this information to improve the behavior of the assistant in future iterations.
Using NPM Packages
Before you beginIt is highly recommended that you include version numbers in your imports to ensure code stability; this will allow you time to verify updates to packages and avoid any potential issues.
node: prefix instead of npm:
Please note that not all NPM packages may function properly inside of Xano. If you encounter an issue importing a specific package, please reach out to our support team for further clarification.
Working with Files
Xano provides a comprehensive set of filesystem functions that allow you to read, write, and manipulate files and directories. These functions are available through the globalDeno namespace.
Reading Files
Read Text Files
Read Binary Files
Read File Stream
Writing Files
Write Text Files
Write Binary Files
Append to Files
File Operations
Check if File Exists
Copy Files
Rename/Move Files
Delete Files
Directory Operations
Create Directory
Read Directory Contents
Remove Directory
File Information
Get File Stats
File Permissions
Temporary Files and Directories
Create Temporary File
Create Temporary Directory
Working with Paths
Deno provides apath module for working with file paths:
Important Notes for Xano Lambda Environment
- In Xano’s Lambda environment, filesystem operations are primarily useful for temporary file operations
- Use the
/tmpdirectory for temporary file storage - Files in the Lambda environment are ephemeral - they will not persist between function calls
- Filesystem operations are useful for:
- Processing uploaded files
- Generating temporary files for processing
- Creating logs or debug information