Your First Vibium Script in JavaScript
Write your first Vibium script in JavaScript: launch Chrome, open a page, find and click elements, and save a screenshot with the sync API in minutes.
Your first Vibium JavaScript script launches Chrome, opens a page, finds an element, and clicks it in about ten lines. Require the sync client, call browser.launch() and bro.page(), navigate with page.go(), locate elements with page.find(), and act with .click() or .type(). Vibium auto-waits for each element, so no manual delays are needed.
What do I need before I start?
You need Vibium installed in a Node.js 18+ project. If you have not set that up, follow How to Install Vibium first:
npm init -y
npm install vibiumThat installs the JavaScript client plus the Go binary that drives Chrome. Create a file named hello.js and you are ready to write code.
How do I write a complete first script?
Paste this into hello.js. It opens a real Chrome window, loads a page, reads a link, saves a screenshot, then clicks the link:
const fs = require("fs");
const { browser } = require("vibium/sync");
// Launch Chrome and grab the default tab
const bro = browser.launch();
const page = bro.page();
// Navigate to a page
page.go("https://example.com");
console.log("Loaded example.com");
// Find an element by CSS selector
const link = page.find("a");
console.log("Link text:", link.text());
// Save a screenshot (screenshot() returns PNG bytes)
const png = page.screenshot();
fs.writeFileSync("example.png", png);
console.log("Saved example.png");
// Click the link
link.click();
console.log("Clicked the link");
// Close the browser
bro.close();Run it:
node hello.jsChrome opens, loads example.com, and closes. A new example.png appears in your folder.
What does each line actually do?
Each call maps to one browser action, which keeps Vibium scripts readable:
| Code | What it does |
|---|---|
browser.launch() | Starts Chrome, returns a browser object |
bro.page() | Returns the default page (tab) |
page.go(url) | Navigates to a URL and waits for load |
page.find(selector) | Locates an element by CSS selector |
el.text() | Returns the element's text content |
el.click() | Clicks the element after auto-waiting |
page.screenshot() | Captures the page as PNG bytes |
bro.close() | Closes the browser |
How do I type into a form field?
Locate the input with find(), then call .type(). Vibium auto-waits until the field is editable before sending keystrokes:
const { browser } = require("vibium/sync");
const bro = browser.launch();
const page = bro.page();
page.go("https://www.google.com");
const box = page.find("textarea[name='q']");
box.type("vibium browser automation");
bro.close();There is no need to poll for the field or retry on a stale element, because Vibium runs actionability checks for you. For a full credential flow, see Automate a login with Vibium.
Should I use the sync or async API?
The example above uses the synchronous API from vibium/sync, which reads top to bottom with no await. Vibium also ships an async API for code that benefits from promises and concurrency:
const { browser } = require("vibium");
async function main() {
const bro = await browser.launch();
const page = await bro.page();
await page.go("https://example.com");
await page.find("a").click();
await bro.close();
}
main();Pick sync for simple linear scripts and async when you are inside an existing async codebase. The Vibium sync vs async guide breaks down exactly when to use each.
Why don't I need waits?
Vibium auto-waits because its Go binary enforces actionability before every interaction. It polls until the target element is visible, stable, enabled, and able to receive the event, up to a 30-second default timeout. That eliminates the flaky setTimeout hacks common in older scripts. This server-side waiting is part of how Vibium works under the hood.
Where do I go next?
You have a working JavaScript script. Compare it with the Python version, dig into sync vs async, or connect the built-in MCP server to Claude Code so an AI agent can drive the browser for you.
Frequently asked questions
How do I write a Vibium script in JavaScript?
Require the sync client with const { browser } = require('vibium/sync'), call browser.launch() to open Chrome and bro.page() for the tab, navigate with page.go(url), locate elements with page.find(selector), then call click() or type(). Close with bro.close(). The whole script is about ten lines.
Does Vibium support TypeScript?
Yes. Vibium ships a JavaScript/TypeScript client, and TypeScript is a first-class target. You import it the same way you would in JavaScript, and the same launch, find, and action methods are available in a TypeScript project.
How do I take a screenshot with Vibium in Node?
Call page.screenshot(), which returns PNG bytes, then write them with fs.writeFileSync('shot.png', png). To capture a single element, call screenshot() on the element returned by page.find() instead of on the page object.
Vibium is created by Jason Huggins. This is an independent tutorial — see the official Vibium site and GitHub repo for canonical docs.
Related guides
Is Vibium Worth Learning in 2026?
Is Vibium worth learning in 2026? An honest breakdown of who it fits, what it costs to learn, and when to pick it over Playwright or Selenium.
14 min read→Getting StartedLearn Vibium in a Weekend
Learn Vibium in a weekend: a 2-day plan to install it, write real browser scripts, add semantic locators, wire up the MCP server, and ship a project.
14 min read→Getting StartedVibium Cheat Sheet (2026)
The complete Vibium cheat sheet for 2026: install, launch, find, click, type, wait, screenshot, and MCP commands with copy-paste JavaScript and Python.
14 min read→Getting StartedUnderstanding Vibium's Installed Folder Structure
What npm install vibium actually puts on disk — the package, the bundled Go binary, the auto-downloaded Chrome, and where Vibium caches everything.
1 min read→