Learn to integrate v0 with Clockify in a few simple steps. Our guide walks you through setup to boost productivity and streamline time tracking.

Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
In your project structure, create a new TypeScript file named clockify.ts. This file will contain the Clockify integration code. Place this file in your project's source folder (for example, in a folder called integrations).
export class Clockify {
private apiKey: string;
private workspaceId: string;
private baseUrl: string = "https://api.clockify.me/api/v1";
constructor(apiKey: string, workspaceId: string) {
this.apiKey = apiKey;
this.workspaceId = workspaceId;
}
// Example function to create a time entry for a user
public async createTimeEntry(
userId: string,
description: string,
startTime: string,
endTime: string
): Promise<any> {
const url = ${this.baseUrl}/workspace/${this.workspaceId}/user/${userId}/time-entries;
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Api-Key": this.apiKey
},
body: JSON.stringify({
description: description,
start: startTime,
end: endTime
})
});
return response.json();
}
// You can add more functions to interact with other Clockify API endpoints as needed.
}
In your main TypeScript file (for example, main.ts), import and initialize the Clockify class. Then, call its functions based on user actions or application events.
import { Clockify } from "./integrations/clockify";
// Replace these with your actual Clockify API key, workspace ID, and user ID.
const APIKEY: string = "yourclockifyapikey";
const WORKSPACEID: string = "yourworkspace_id";
const USERID: string = "youruser_id";
// Initialize the Clockify integration
const clockify = new Clockify(APIKEY, WORKSPACEID);
// Example: Create a new time entry when a button is clicked
const startButton = document.getElementById("startButton");
startButton?.addEventListener("click", async () => {
const description = "Work session";
const startTime = new Date().toISOString();
// Simulate an end time two hours from now
const endTime = new Date(Date.now() + 2 60 60 * 1000).toISOString();
try {
const result = await clockify.createTimeEntry(USER_ID, description, startTime, endTime);
console.log("Time entry created:", result);
} catch (error) {
console.error("Error creating time entry:", error);
}
});
Since your v0 project does not have a terminal, you need to include any required dependencies directly in your code. The Clockify integration in this guide uses the built-in fetch API, so no additional HTTP libraries are needed. If you require external TypeScript definitions or polyfills, add them as script tags in your index.html file.
For example, if you need a polyfill for older browsers:
<script src="https://unpkg.com/[email protected]/dist/fetch.umd.js"></script>
Place this script tag in the head section of your index.html file.
Ensure that your project is set up to compile TypeScript to JavaScript. Include the compiled JavaScript files in your index.html. If your project automatically compiles TypeScript, the output file (for example, main.js) should be referenced from the HTML file like this:
<script src="path/to/compiled/main.js"></script>
This will load your application code that integrates Clockify.
Open your application in the browser and click the button (with id "startButton") to trigger the time entry creation. Open the browser’s console to view logs and confirm that the entry is created successfully on Clockify. Adjust the parameters (API key, workspace ID, user ID, and timings) as necessary.
When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.