Velo by Wix is an innovative product that lets you build robust web applications with zero setup. Work in Wix's visual builder, add custom functionality and interactions using Velo APIs, and enjoy serverless coding in both the front-end and backend. With Velo, your web app can be up and running in a fraction of the time it would normally take you.To introduce you to Velo, we created our own version of a "Hello, World!" example: a simple currency converter site that uses the wix-fetch API to connect to a third-party service. Site visitors choose source and target currencies from dropdowns and enter an amount to convert. The results are displayed in a text box.
Follow the steps below to get familiar with the basic structure and syntax of Velo.

Step 1: Create a New Wix Site

  1. Sign into your Wix account or sign up for a Wix account if you don’t already have one.
  2. Open a blank template in the Editor.

Step 2: Enable Velo

Enable Velo in the Wix Editor to let you work with code in your site.

Step 3: Add Elements to the Page

Add page elements in the Wix Editor: 
  1. On the left side of the Editor, click Add.
  2. Add the page elements illustrated below to your site.
    • When you add each element, set its ID in the Properties & Events panel that appears on the right side of the Code Panel. Use the name shown below for each element, minus the hashtag. See the table below for a full list of the elements and where to find them in the Add menu.
Element: Dropdown
Location in Add Menu:
User Input
Description: For selecting the source currency
ID: sourceCurrency
Element: Dropdown
Location in Add Menu: User Input
Description: For electing the target currency
ID: targetCurrency
Element: Input
Location in Add Menu: User Input
Description: For entering the amount to convert
ID: sourceAmount
Element: Textbox
Location in Add Menu: User Input
Description: To display the converted amount
ID: targetCurrency
Element: Button
Location in Add Menu: Button
Description: To trigger the currency conversion when clicked
ID: calculateButton

Step 4: Add Code

NOTES:
All the code for this example is added to a single page on the site. In this section we divided the code into short blocks followed by explanations. To see the complete code for this example without comments, scroll down to the end of the tutorial. 

See our API Reference to learn more about the Velo-based code in this example.
To add the code:
  1. Double-click Home Page Code at the bottom of the Editor to open the Code Panel.
  2. Add the following code to the top of the code in the tab before the onReady function:
  1. Click Preview at the top right of the Editor.
  2. Enter an amount in the source currency input.
  3. Click the calculate button and see the converted currency result in the target amount text box.
  4. Publish your site to make it live and production ready.
That's it! In just a few minutes, you created a web application in Velo! No setup, no managing server infrastructure, just integrating Velo APIs with the Wix visual builder.

Next Steps

Now that you've had a taste of Velo, check out what else you can do:

Example Code

Here is the complete code for this example, without comments:
import {getJSON} from 'wix-fetch';

const url = "https://api.exchangeratesapi.io/latest";

let currencyOptions = [
  { "value": "USD",  "label": "US Dollars"},
  { "value": "EUR",  "label": "Euros"},
  { "value": "JPY",  "label": "Japanese Yen"},
];

$w.onReady(function () {
  populateDropdowns();
 
  $w('#calculateButton').onClick((event) => {
    calculateCurrency();
  })
});

function populateDropdowns(){
  $w('Dropdown').options = currencyOptions;
  $w('Dropdown').selectedIndex = 0;
}

function calculateCurrency() {
  let initialAmount = $w("#sourceAmount").value;
  let sourceSymbol = $w("#sourceCurrency").value;
  let targetSymbol = $w("#targetCurrency").value;
  let fullUrl = `${url}?base=${sourceSymbol}&symbols=${targetSymbol}`;

  getJSON(fullUrl)
  .then(json => {
    $w("#targetAmount").value = initialAmount * json.rates[targetSymbol];
  }
)}