> ## Documentation Index
> Fetch the complete documentation index at: https://docs.noclick.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Code

> Run custom JavaScript or Python in a workflow with the Serverless Function node.

The Serverless Function node runs your own code. Pick a runtime, define named inputs that map data from upstream nodes, and write a function body. Whatever you `return` becomes the node's `result`, which downstream nodes reference as `{{code-id.result}}`.

<Tip>
  For a one-off string or number transform, you may not need this node at all, write an [inline expression](/editor/data-references) directly in the field instead, e.g. `{{ $('form').email.split("@")[1] }}`.
</Tip>

## Inputs

**Function Inputs** is a list of name + value pairs. The value is usually a reference like `{{sheets-1.values}}`. In JavaScript, inputs are available on the `inputs` object (`inputs.data`); in Python, each input becomes a function argument with its name (`data`).

## JavaScript

Runs in QuickJS and starts in milliseconds, so it's the right choice for quick data transformations. Pure JavaScript only: no npm packages, no network access, and a 3 second execution limit. `console.log` output is captured as `stdout`.

```javascript theme={null}
// Input "data" mapped from {{sheets-1.values}}
const emails = inputs.data
  .filter(row => row.status === 'active')
  .map(row => row.email);
return { emails, count: emails.length };
```

## Python

Runs in a cloud sandbox with installable pip packages and optional GPUs. Use it for heavy computation, ML workloads, or anything that needs libraries. This sandbox is NoClick's compute, so a Python run costs credits based on the CPU, memory, and GPU you reserve and how long it runs, billed even if the run errors or times out. JavaScript runs in-process and is free. See [What costs credits](/billing/costs).

| Field                 | What it does                                                                                                                               |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| **Function Body**     | Python code; `return` a JSON-serializable value                                                                                            |
| **Requirements**      | pip packages to install, one per line                                                                                                      |
| **Hardware**          | **GPU Type** (CPU only, T4, L4, A10G, A100 40GB, A100 80GB, H100), **GPU Count** (1-8), **CPU Cores** (0.25-16), **Memory** (256 MB-64 GB) |
| **Timeout (seconds)** | Up to 3600, default 300                                                                                                                    |
| **Region**            | Auto (nearest), US East, US West, EU West, EU Central                                                                                      |

```python theme={null}
# Input "data" mapped from an upstream node
import pandas as pd  # add "pandas" to Requirements
df = pd.DataFrame(data)
return {"mean": df["price"].mean(), "rows": len(df)}
```

<Tip>
  Need values to persist between runs (counters, seen IDs)? Connect a [State Manager](/logic/variables-state) node to get a mutable `state` parameter that saves automatically.
</Tip>

## Next steps

* [Variables and state](/logic/variables-state)
* [HTTP request](/logic/http-request)
