Your First Component

1. What is vwf ?

Vicinity World Framework (vwf) is built on VanJS - an ultra-lightweight (1.5KB) reactive JavaScript framework. Unlike React, Vue, or Angular, vwf has zero dependencies and requires no build tools to get started.

💡Important: vwf is 100x smaller than React (1.5KB vs 140KB+) while being fully capable of building complex applications.
  • ✨ Direct DOM manipulation (no virtual DOM)
  • ⚡ True reactivity with van.state()
  • 🎯 Simple, predictable patterns
  • 📦 Import as ES6 modules - no bundler needed

2. Hello World (3 min)

The simplest vwf component is a function that returns DOM elements. Here's your first component:

import van from 'vanjs-core';
const { div, h1 } = van.tags;

// Your first component!
export const component = () => {
  return div(
    h1('Hello, VWF!')
  );
};

Breaking it down: van.tags gives you functions for creating HTML elements. Each function (div, h1, p, etc.) creates that element.

✅Best Practice: Tag functions are just JavaScript - no JSX, no special syntax, no magic!

3. Your First Page (5 min)

vwf uses file-based routing. Create a file and it becomes a route automatically:

// File: /demo/src/app/hello/page.js
import van from 'vanjs-core';
const { div, h1, p } = van.tags;

export const component = () => {
  return div(
    { class: 'max-w-4xl mx-auto p-8' },
    h1({ class: 'text-3xl font-bold mb-4' }, 'Hello, VWF!'),
    p({ class: 'text-smoke' }, 'This is your first page.')
  );
};
💡Important: File structure = URL structure. /app/hello/page.js → /hello route. No configuration needed!
  • page.js = A route that renders
  • layout.js = Wraps child pages (optional)
  • component export = Must be named "component"

4. Run It (5 min)

Start the development server and see your page live:

# In your terminal
cd demo
npm run dev

# Open browser to:
https://dev.pakasa.world/demo/hello
✅Best Practice: Hot module replacement (HMR) is built-in. Edit your code and see changes instantly!

🎯 Your First Component Checklist

  • ✅Import van and destructure tags
  • ✅Export component function
  • ✅Return DOM elements from tag functions
  • ✅Use Tailwind classes for styling
  • ✅File-based routing (page.js)
  • ✅Run npm run dev to see it live

Explore vwf

Discover what vwf can do