Functions

Turn your words into logic that runs in the cloud

Functions let you make backends to power your projects. Here's why they're powerful:

  • Turn your words into logic. Describe the inputs, logic, and outputs. Create turns it into code that runs.

  • Separate concerns. You can split up defining your UI from defining the core business logic of your tool.

  • Reusable. Once perfected, you can use your Function across any page or component.

  • Composable. Your function can use any of our built in Integrations, Databases or even other Functions.

  • Secrets. Functions run in the cloud so you can securely store API keys, passwords, and other secrets with our new Secrets Manager. Create will know how to use them when generating your Function.

  • Use External APIs. Functions can connect with (almost) any external API. You can include your own API keys as Secrets - so you can make your own integrations. Integrate with Stripe, Hubspot, and 1000s more.

With Functions, you can build powerful and flexible logic for your projects.

Getting Started

  1. You make a new Function from the dashboard or the project menu.

  1. Describe the inputs (if any), what you want the Function to do, and the outputs (if any)

  1. Create will generate a flow diagram for your Function's logic that you can inspect. You can also read the code with the "View Code" button. If something is not quite right, add details and re-generate.

  2. Test your Function with sample inputs and verify that the outputs are what you expect.

  3. Use your Function in any Page, Component, or other Functions.

Test Your Function

You can test Functions with sample inputs from the Test tab.

Sample Inputs

After you define your inputs, you can enter them either as a Form or JSON.

In this example, there is 1 input called query for a Function that performs search. Create guesses a placeholder based on your Function definition that you should update or can use.

Running Tests and History

Hit "Run function" with inputs entered to test the function.

You'll see a history of previous tests. Tests can either be "Pending", "Running", "Completed", or "Error".

Outputs and Errors

In each test run, you'll see the inputs and outputs/errors.

Outputs will be shown as a JSON object. If the outputs do not match the shape that you expect, add more details on how you would like outputs to be formatted/structured, and re-generate the function.

If there's an Error, you should see a generated English description of what the error likely is; along with the "View Code" button, this description can help you re-generate your Function to fix the Error.

If you need help getting your Function to work, join our Discord and post in the "help-me-build" channel.

Use Your Function

You can use Functions in Pages, Components, and even other Functions.

Similar to Integrations, press "/" or open the "Add-ons" menu to include a Function in your prompt.

When you generate your prompt with your Function referenced, Create figure outs how to hook your Function up to the page, component, or function based on your description, the function inputs, and the function outputs.

If it's not working well, add more details to your prompt on exactly how you want it to interact.

If you need help getting your Function integrated into your page, component, or function, join our Discord and post in the "help-me-build" channel.

Make more powerful Functions with Integrations, Databases, and External APIs

Your Function can take advantage of our built in Integrations and Databases.

Press "/" or open the "Add ons" menu to reference an integration or database. Add a description of how you'd like to to use it.

External APIs

The most powerful feature of Functions is that they can use External APIs. This allows you to make your own "integrations" - make a Function that uses the API how you'd like, and then use that Function in other pages, components, and functions.

To use an External API:

  1. If the API needs authentication via token, username, or password, be sure to store it as a well-named Secret. Note: for now, Functions cannot use External APIs that authenticate via OAuth as there's not a secure way to store the OAuth token (and it will expire)

  2. Tell your Function to use the API you want. Create will figure out how to integrate your secret. If you need more specifics, copy and paste the docs of your API.

  3. Test your Function. Note: for now, Create needs to perform tests against your live API so make sure API calls you tell Create to make are safe.

Here are some common APIs and where to find your API keys:

Here is an in-depth YouTube video tutorial on how to connect to an external API, using the Exa AI Search API:

You can also use Zapier, Make, and other platforms that connect to APIs by using their "webhook" triggers. Here's a YouTube video with the steps:

Updating and Publishing Functions

Updating Functions while building

If you include a Function in a pages, components, or another function, they use the version of your Function that existed when you first referenced it in their prompt. As you make updates to your Function, you need to hit the refresh button on the Function reference in the places it's used. This allows you to control when the integrations should use the latest version of your function.

Publishing Functions with your app

When you want to go live with your app so that your users can use it, similar to pages, you need to Publish your Functions. This locks the current version of the Function as the "Published" version. Your app uses the Published version of the Function, and you can make future iterations on the Function with confidence it won't break the app. If you make upgrades that you want to roll out to the app, you can update the published version of the Function.

To publish, choose a route for the function. You can also turn Functions on or off.

Last updated