Xano Documentation
Search…
πŸ’‘
Start here
☁️ Your Xano Account
πŸ’²
Special Discount Pricing
Lambdas (JavaScript)

Lambdas seem to have multiple definitions depending on who you ask... anonymous functions, serverless functions, a snippet of code, etc. The most important takeaway is that it is a way to do business logic in a lightweight manner and return a result using a programming language.
The most popular programing language for Lambda support is JavaScript.

Serverless computing is a concept (and buzzword) where code can be executed by some other service. This allows you to not have to worry about maintaining your own server. From your point of view it may feel like it is serverless, but there is still a server somewhere processing the Lambda code and returning a result. Xano's implementation of Lambdas are processed on their own servers. Since Xano maintains its own servers and you are supplying the code to be processed, one could make the case that Xano's Lambdas are serverless. There is still a bit more nuance to consider, when comparing different serverless solutions to each other, but the main benefit of Xano's implementation is that it is all contained within Xano, which means any Xano customer can get started using it right away.

Yes, Xano is 100% the No Code backend. More importantly, it is a Turing-complete backend, which means it can do anything a programming language can do through variables, conditionals, and loops.
The Lambda feature is a bit taboo, since technically it means that by allowing it to exist, one could argue that Xano has become a Low Code solution. We have thought long and hard on this topic and we strongly believe that the power of Xano increases with this Lambda functionality and we are letting our users decide if they want to use it or not.
For No Code purists, Xano will remain the No Code backend. For Low Code advocates, Xano will have offerings such as Lambda support. Regardless what you choose, Xano will always remain true to its roots and remain a No Code first solution.

Lambdas have the same ability to access anything in the function stack as normal statements and filters currently do. They just have the ability to interact and transform data using JavaScript. See below for some capabilities to be on the lookout as you start exploring Lambdas.

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 $var special variable. To access a Xano variable named title, you would reference it as $var.title.
  • Xano inputs are accessible through the $input special variable. To access a Xano input named score, you would reference it as $input.score.
  • Xano environment variables are accessible through the $env special variable. To access a Xano environment variable named ip, you would reference it as $env.ip.

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.

One advantage of using Lambda support is that you have the ability to use powerful JavaScript libraries and functions from 3rd parties. Xano includes support for the following:
Xano currently doesn't support loading external libraries, but we may be able to include additional capabilities by request. If you have a favorite, then please let us now on our feedback board.

Xano supports Lambdas as a function stack statement, a filter, and as an argument to higher-order functions.

Add a Lambda function to the function stack,
This is the most basic use of Lambda support. It is used within the function stack and has access to all inputs, environment variables, and the current state of variables just like all function stack statements have. The purpose of this version of Lambda is to reference the required data that is accessible to it, perform some type of transformation, and then return a result, which is then stored within the name of the variable specified within this statement.
Lambda functions are inserted in the function stack and can interact with inputs and variables.
Here is an example of a function stack where there is an input named multiplier and a variable named amount. We use the function stack version of our Lambda support to multiply the two together and then return it as a new variable named answer.
return $input.multiplier * $var.amount;

Lambda can also be executed as a filter.
This version of our Lambda support has one major difference between the function stack statement equivalent. The context of the expression prior to the filter is available through a context variable named $this. This allows you to perform Lambdas in a very light weight manner as well as have the ability to chain multiple Lambdas together through the filter stack.
Using the same example as above we can reproduce this applying a Lambda filter on the amount variable, which then lets us access it through the $this context variable.
Lambda filter using the $this variable to represent the variable where the filter is applied.
return $input.multiplier * $this;

These types of filters are very powerful because they perform some type of operation (most commonly on an array of values) and use a Lambda as the input of the higher order function. In the array use case the Lambda would be processed on each element of the array and each processing of the Lambda would have access to context variables that are applicable to each filter.
Copy link
On this page
What is a Lambda?
Is this considered Serverless computing?
Wait a second... isn't Xano the No Code backend?
What can I do with a Lambda?
Special Variables
Context Variables
Library/Function Variables
How do I use a Lambda?
Function Stack
Filter
Higher Order Filters