Skip to content
/ van Public
forked from vanjs-org/van

๐ŸฆVanJS: World's smallest reactive UI framework - Everyone can build a useful UI app in an hour

License

Notifications You must be signed in to change notification settings

efpage/van

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿฆ VanJS: The Smallest Reactive UI Framework in the World

๐Ÿ“ฃ VanJS 1.0.0 is here โ†’

Enable everyone to build useful UI apps with a few lines of code, anywhere, any time, on any device.

VanJS is an ultra-lightweight, zero-dependency and unopinionated Reactive UI framework based on pure vanilla JavaScript and DOM. Programming with VanJS feels like building React apps in a scripting language, without JSX. Check-out the Hello World code below:

// Reusable components can be just pure vanilla JavaScript functions.
// Here we capitalize the first letter to follow React conventions.
const Hello = () => div(
  p("๐Ÿ‘‹Hello"),
  ul(
    li("๐Ÿ—บ๏ธWorld"),
    li(a({href: "https://vanjs.org/"}, "๐ŸฆVanJS")),
  ),
)

van.add(document.body, Hello())
// Alternatively, you can write:
// document.body.appendChild(Hello())

Try on jsfiddle

You can convert any HTML snippet into VanJS code with our online converter.

VanJS helps you manage states and UI bindings as well, with a more natural API:

const Counter = () => {
  const counter = van.state(0)
  return div(
    "โค๏ธ ", counter, " ",
    button({onclick: () => ++counter.val}, "๐Ÿ‘"),
    button({onclick: () => --counter.val}, "๐Ÿ‘Ž"),
  )
}

van.add(document.body, Counter())

Try on jsfiddle

Why VanJS?

Reactive Programming without React/JSX

Declarative DOM tree composition, reusable components, reactive state binding - VanJS offers every good aspect that React does, but without the need of React, JSX, transpiling, virtual DOM, or any hidden logic. Everything is built with simple JavaScript functions and DOM.

Grab 'n Go

No installation, no configuration, no dependencies, no transpiling, no IDE setups. Adding a line to your script or HTML file is all you need to start coding. And any code with VanJS can be pasted and executed directly in your browser's developer console. VanJS allows you to focus on the business logic of your application, rather than getting bogged down in frameworks and tools.

Ultra-Lightweight

VanJS is a very thin layer on top of Vanilla JavaScript and DOM, barely enough to make the DOM manipulation and state binding as ergonomic as (if not more than) React, and it delegates most of work to standard browser APIs implemented in native code. As a result, the bundled size of VanJS is just 1.7kB (0.9kB gzipped), which is 50~100 times smaller than most popular UI frameworks, making it the smallest reactive UI framework in the world:

Size comparison

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.

-- Antoine de Saint-Exupรฉry, Airman's Odyssey

TypeScript Support

VanJS provides first-class support for TypeScript. Simply download the corresponding .d.ts file along with your .js file, and you'll be able to take advantage of type-checking, IntelliSense, large-scale refactoring provided by your preferred development environment. Refer to the Download Table to find the right .d.ts file to work with.

Easy to Learn

Simplicity at its core. 5 major functions (van.tags, van.add, van.state, van.derive, van.hydrate) + 4 auxiliary functions (van.tagsNS, van._, van.val, van.oldVal). The walkthrough tutorial is the same as the full API reference, and can be learned within 1 hour for most developers.

Want to Learn More?

Support & Feedback

๐Ÿ™ VanJS aims to build a better world by reducing the entry barrier for UI programming, with no intention or plan on commercialization whatsoever. If you find VanJS interesting, or could be useful for you some day, please consider starring the project. It takes just a few seconds but your support means the world to us and helps spread VanJS to a wider audience.

In the name of Vanilla of the House JavaScript, the First of its name, Smallest Reactive UI Framework, 0.9kB JSX-free Grab 'n Go Library, Scripting Language for GUI, ChatGPT-Empowered Toolkit, by the word of Tao of the House Xin, Founder and Maintainer of VanJS, I do hereby grant you the permission of VanJS under MIT License.

Contact us: @taoxin / [email protected] / Tao Xin

Community Add-ons

VanJS can be extended via add-ons. Add-ons add more features to VanJS and/or provide an alternative styled API. Below is a curated list of add-ons built by VanJS community:

  • van_dml.js: adds a a new flavour of composition to VanJS. Author: Eckehard.
  • van-jsx: a JSX wrapper for VanJS, for people who like the JSX syntax more. Author: cqh963852.

Contributors (24)

If I miss anyone's contribution here, apologies for my oversight ๐Ÿ™, please comment on #87 to let me know.

Tao Xin
Tao Xin

๐ŸŽจ ๐Ÿ’ป ๐Ÿ“– ๐Ÿ’ก
Ryan Olson
Ryan Olson

๐Ÿ–‹
Tamotsu Takahashi
Tamotsu Takahashi

๐Ÿ’ป
icecream17
icecream17

๐Ÿ’ป
enpitsulin
enpitsulin

๐Ÿ’ก ๐Ÿ’ป
Elliot Ford
Elliot Ford

๐Ÿ’ป
andrewgryan
andrewgryan

๐ŸŽจ ๐Ÿ’ป ๐Ÿ›
FredericH
FredericH

๐Ÿ’ก ๐Ÿ’ป
ebraminio
ebraminio

๐Ÿ’ป โš ๏ธ
Eckehard
Eckehard

๐Ÿ’ป ๐Ÿ”Œ
Austin Merrick
Austin Merrick

๐Ÿ’ป ๐Ÿค” ๐ŸŽจ
Lee Byonghun
Lee Byonghun

๐Ÿ’ป
caputdraconis
caputdraconis

๐Ÿ’ป
Achille Lacoin
Achille Lacoin

๐Ÿ’ป
cqh
cqh

๐Ÿ’ป ๐Ÿ”Œ
awesome
awesome

๐Ÿ“น
artydev
artydev

๐Ÿ’ก ๐Ÿ’ฌ
Neven DREAN
Neven DREAN

๐Ÿ’ก ๐Ÿ›
Stephen Handley
Stephen Handley

๐Ÿ’ก
Ionut Stoica
Ionut Stoica

๐Ÿค”
Rasmus Schultz
Rasmus Schultz

๐Ÿค”
cloudspeech
cloudspeech

๐Ÿค”
Daniel Upshaw
Daniel Upshaw

๐Ÿ”Œ
barrymun
barrymun

๐Ÿ’ก

About

๐ŸฆVanJS: World's smallest reactive UI framework - Everyone can build a useful UI app in an hour

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 87.9%
  • TypeScript 11.1%
  • Other 1.0%