/svenjs

A JavaScript framework for composable web apps

Primary LanguageJavaScript

SvenJS

A JavaScript framework for composable web apps

Demos

Releases

  • 2.0.2: ES modules, bug fixes and more!
  • 0.3.2: Added _beforeMount life cycle method.
  • 0.3.1: Added composition (importing components and referencing them in JSX by name). For instance: const SecondComponent = require("SecondComponent"). Referenced in render like this:
  • 0.3.0: Renamed life cycle methods. New names: _didMount & _didUpdate

Features

  • Enforced state immutability

  • Minimal file size

Goals

  • Can be used in a browser script tag (almost there)

  • A web library that enables you to write code that can be accessed both serverside and clientside

  • Built in store implementation (todo)

Install

Use the npm version:

  npm install svenjs

Build youself. Clone this repo and run

  npm run build

How to use

import SvenJs from "svenjs";

SvenJs.create({
    initialState: {
        clicks: 0
    },
    render() {
    const clickFunc = () =>{
      let clicks=this.state.clicks;
      this.setState({clicks: ++clicks });
    }
    return (<div id="row">
            <h3>The Click App</h3>
            <div>
              <button onClick={clickFunc}>Click me?</button>
            </div>
        <div>
            <h3>Click stats</h3>
          <p>You have clicked on the button {this.state.clicks} times</p>
        </div>
    </div>)
    }
});
SvenJs.render(App, document.getElementById("app"))

Related Modules