• Stars
    star
    1,172
  • Rank 38,616 (Top 0.8 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 7 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

AppRun is a JavaScript library for developing high-performance and reliable web applications using the elm inspired architecture, events and components.

AppRun Build NPM version Downloads License twitter Discord Chat

AppRun is a JavaScript library for building reliable, high-performance web applications using the Elm-inspired architecture, events, and components.

// define the application state
const state = 0;

// view is a pure function to display the state
const view = state => `<div>
  <h1>${state}</h1>
  <button onclick="app.run('-1')">-1</button>
  <button onclick="app.run('+1')">+1</button>
</div>`;

// update is a collection of event handlers
const update = {
  '+1': state => state + 1,
  '-1': state => state - 1
};
app.start(document.body, state, view, update);

AppRun Benefits

  • Clean architecure that needs less code
  • State management and routing included
  • No proprietary syntax to learn (no hooks)
  • Use directly in the browser or with a compiler/bundler
  • Advanced features: JSX, Web Components, Dev Tools, SSR, etc.

Getting Started

AppRun is distributed on npm. To get it, run:

npm install apprun

You can also load AppRun directly from the unpkg.com CDN:

<script src="https://unpkg.com/apprun/dist/apprun-html.js"></script>
<script>
  const view = state => `<div>${state}</div>`;
  app.start(document.body, 'hello AppRun', view);
</script>

Or, use the ESM version:

<script type="module">
  import { app } from 'https://unpkg.com/apprun/dist/apprun-html.esm.js';
  const view = state => `<div>${state}</div>`;
  app.start(document.body, 'hello ESM', view);
</script>

Or, you can create an AppRun app by using the npm create apprun-app command.

npm create apprun-app [my-app]

Component and Web Component

An AppRun component is a mini-application with elm architecture, which means inside a component, there are state, view, and update. In addition, components provide a local scope.

class Counter extends Component {
  state = 0;
  view = state => {
    const add = (state, num) => state + num;
    return <>
      <h1>{state}</h1>
      <button $onclick={[add, -1]}>-1</button>
      <button $onclick={[add, +1]}>+1</button>
      </>;
  }
}
app.render(document.body, <Counter/>);

You can convert AppRun components into web components/custom elements. AppRun components become the custom elements that also can handle AppRun events.

class Counter extends Component {
  state = 0;
  view = state => {
    const add = (state, num) => state + num;
    return <>
      <h1>{state}</h1>
      <button $onclick={[add, -1]}>-1</button>
      <button $onclick={[add, +1]}>+1</button>
      </>;
  }
}
app.webComponent('my-app', Counter);
app.render(document.body, <my-app />);

All the Ways to Make a Web Component - May 2021 Update compares the coding style, bundle size, and performance of 55 different ways to make a Web Component. It put AppRun on the top 1/3 of the list of bundle size and performance.

Learn More

You can get started with AppRun Docs and the AppRun Playground.

AppRun Book from Apress

Order from Amazon

Contribute

You can launch the webpack dev-server and the demo app from the demo folder with the following npm commands:

npm install
npm start

You can run the unit tests from the tests folder.

npm test

Unit tests can serve as functional specifications.

Finally, to build optimized js files to the dist folder, just run:

npm run build

Have fun and send pull requests.

Contributors

Support

AppRun is an MIT-licensed open source project. Please consider supporting the project on Patreon. ๐Ÿ‘โค๏ธ๐Ÿ™

Thank you for your support

  • Athkahden Asura
  • Alfred Nerstu
  • Gyuri Lajos
  • Lorenz GliรŸmann
  • Kevin Shi
  • Chancy Kennedy

License

MIT

Copyright (c) 2015-2022 Yiyi Sun

More Repositories

1

Git-Source-Control-Provider

Git Source Control Provider is a visual studio plug-in that integrates Git with visual studio solution explorer.
C#
200
star
2

Git-Web-Access

The project provides a Git smart HTTP backend on IIS.
C#
89
star
3

git-tools

This extension provides a git changes tool window, a graphical git history viewer and menus to launch Git Bash, Git Extenstions and TortoiseGit.
C#
77
star
4

apprun-site

AppRun Site, a framework for AppRun applications.
JavaScript
14
star
5

apprun-hn

A Hacker News reader application built using AppRun
TypeScript
13
star
6

apprun-websockets-sqlite

AppRun database-driven application using WebSockets without REST API
JavaScript
11
star
7

Rabbit

Rabbit is lightweight framework for building web sites using WebMatrix (ASP.NET Web Pages with Razor Syntax).
C#
11
star
8

apprun-ssr-aspnet-core

This project demonstrates generating virtual DOM on server-side for ASP.NET MVC Core.
C#
10
star
9

apprun-dapr

JavaScript
8
star
10

apprun-apress-book

CSS
7
star
11

apprun-ssr

AppRun server-side rendering example
TypeScript
6
star
12

dragon-core

C#
6
star
13

apprun-websockets

TypeScript
4
star
14

apprun-ssr-aspnet

This project demonstrates generating virtual DOM on server side using ASP.NET MVC filter.
C#
4
star
15

Dragon

C#
3
star
16

cac

Computer Cartography
Java
3
star
17

apprun-firebase

A serverless application using Firebase and AppRun
TypeScript
3
star
18

tsc-init

This is a tool to initialize TypeScript and Webpack in your project.
JavaScript
3
star
19

apprun-rust

AppRun Rust Demo App
JavaScript
2
star
20

apprun-d3

TypeScript
2
star
21

apprun-dynamic-components

TypeScript
2
star
22

apprun-ssr-express

JavaScript
2
star
23

apprun-firebase-authentication

TypeScript
2
star
24

apprun-logseq-clone

TypeScript
1
star
25

apprun-wasm

Rust
1
star
26

apprun-f7

TypeScript
1
star
27

apprun-docs

HTML
1
star
28

apprun-electron

TypeScript
1
star
29

apprun-course-2021

TypeScript
1
star
30

apprun-hot-module-reload

This project demonstrates the configurations and code snippets required to support Hot Module Reload in an AppRun application.
TypeScript
1
star
31

apprun-dev-server

JavaScript
1
star