Skip to main content

Connect the Frontend

Connecting the frontend and backend of a project is an essential step in creating a fully functional web application by enabling data communication and interaction between the user interface and the server.

In this section, you'll learn how to connect the frontend of your project to the linktree task. Connecting a frontend to a deployed Koii task is no different from connecting to a regular backend; it can be easily done by following these steps:

1. Implement API Functions

API functions serve the purpose of sending HTTP requests and interacting with the backend's endpoints (e.g., GET, POST, PUT, DELETE). Begin by creating API functions for the various HTTP requests.

Here is an example illustrating how the POST request method is implemented in the linktree project:

async function setLinktree(data, publicKey, nodeList, username) {
let result;
while (!result && nodeList[nodeListIndex]) {
try {
// Send a POST request using axios to the specified endpoint
const response = await
`${nodeList[nodeListIndex]}/task/${TASK_ADDRESS}/linktree`, {payload,}
result =;

// ... check the repository for the full code

The backend endpoint is ${node}/task/${TASK_ADDRESS}/linktree/

  • node refers to the first node that sends a successful response.
  • TASK_ADDRESS is the address to which the task was deployed.

In the above code block, we iterate through the nodeList until a successful response is received. If you use a console.log for the backend endpoint, you may retrieve a link similar to this: ""

2. Integrate User Interface

Integrate the API function into the user interface as shown below:

import { setLinktree } from "../api";

const CreateLinktree = () => {
// ... check the repository for the full code

const res = await setLinktree(

// Component JSX and logic

By following these steps, your frontend will seamlessly interact with the backend, enabling a smooth flow of data and enhancing the overall functionality of your web application.

Please refer to the repository for comprehensive code examples and further details.