Learn WIX-CORVID with Real Code Examples
Updated Nov 26, 2025
Code Sample Descriptions
1
Simple Backend API with Corvid
// backend/hello.jsw
export function sayHello(name) {
return `Hello, ${name}! Welcome to my Wix site.`;
}
// Example frontend usage:
import { sayHello } from 'backend/hello.jsw';
$w.onReady(function () {
sayHello('Alice').then((msg) => {
console.log(msg);
});
});
A backend function in Wix Corvid that returns a greeting message as an HTTP endpoint.
2
Simple Dataset Query Example
// backend/getItems.jsw
import wixData from 'wix-data';
export function fetchAllItems() {
return wixData.query('MyCollection').find();
}
$w.onReady(function () {
fetchAllItems().then((results) => {
console.log(results.items);
});
});
Fetches all items from a dataset and logs them.
3
Insert Item into Collection
// backend/addItem.jsw
import wixData from 'wix-data';
export function addNewItem(title) {
return wixData.insert('MyCollection', { title });
}
$w.onReady(function () {
addNewItem('Test Item').then((item) => console.log(item));
});
Adds a new item to a Wix collection.
4
Update Item in Collection
// backend/updateItem.jsw
import wixData from 'wix-data';
export function updateItem(id, newTitle) {
return wixData.update('MyCollection', { _id: id, title: newTitle });
}
$w.onReady(function () {
updateItem('abc123', 'Updated Title').then(console.log);
});
Updates an existing item in a collection by ID.
5
Delete Item from Collection
// backend/deleteItem.jsw
import wixData from 'wix-data';
export function deleteItem(id) {
return wixData.remove('MyCollection', id);
}
$w.onReady(function () {
deleteItem('abc123').then(() => console.log('Deleted'));
});
Deletes an item from a collection by ID.
6
Send Email Example
// backend/sendEmail.jsw
import wixCRM from 'wix-crm-backend';
export function sendWelcomeEmail(email) {
return wixCRM.emailContact('WelcomeTemplate', email);
}
$w.onReady(function () {
sendWelcomeEmail('test@example.com').then(() => console.log('Email sent'));
});
Sends an email using Wix Email API.
7
Simple HTTP Function
// backend/httpHello.jsw
import { ok, notFound } from 'wix-http-functions';
export function get_hello(request) {
return ok({
body: 'Hello from Wix HTTP Function'
});
}
Exposes a backend function as an HTTP endpoint in Wix.
8
Fetch Data with Promise
// backend/fetchData.jsw
import wixData from 'wix-data';
export function getItemsAsync() {
return new Promise((resolve, reject) => {
wixData.query('MyCollection').find()
.then(res => resolve(res.items))
.catch(err => reject(err));
});
}
$w.onReady(function () {
getItemsAsync().then(console.log);
});
Uses a Promise to fetch data from a collection asynchronously.
9
Create Custom Object
// backend/customObject.jsw
export function getCustomData() {
return { message: 'Hello from Wix backend', time: new Date() };
}
$w.onReady(function () {
import { getCustomData } from 'backend/customObject.jsw';
console.log(getCustomData());
});
Creates and returns a custom object to frontend.
10
Backend Validation Function
// backend/validate.jsw
import wixData from 'wix-data';
export function validateAndSave(item) {
if(!item.title) throw new Error('Title is required');
return wixData.insert('MyCollection', item);
}
$w.onReady(function () {
validateAndSave({ title: 'Test' }).then(console.log).catch(console.error);
});
Validates input data in the backend before saving to collection.