You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/liveviewjs.com/docs/01-overview/introduction.md
+36-27Lines changed: 36 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,23 +11,39 @@ far less code and complexity and far more speed and efficiency**.
11
11
12
12
## What is a LiveView?
13
13
14
-
A LiveView is a server-rendered HTML page that connects to the server via a persistent web socket. The web socket allows
15
-
the client to send user events to the server and the server to send diffs in response. **LiveViewJS** is a LiveView
16
-
framework that handles the complex part of this (handling websockets, diffing changes, applying DOM updates, etc.) so that
17
-
you can focus on building your application.
14
+
The LiveView pattern, [as popularized in Elixir’s Phoenix framework](https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.html), shifts your UI’s state management, event handling to the server, calculating minimal diffs to drive updates in your HTML over WebSockets.
18
15
19
-
Here's the typical "counter" example written as a LiveView in **LiveViewJS**:
16
+
There are many benefits to this approach, including:
17
+
* extremely fast, SEO-friendly page loads
18
+
* simple state management that works well at any scale (not just small apps)
19
+
* minimal data transfer (only send diffs)
20
+
* no need to build (or operate) REST or GraphQL APIs
21
+
22
+
There are also some drawbacks, including:
23
+
* requires a server (e.g. pure static sites are not the best fit)
24
+
* requires a internet connection (e.g. offline-first apps are not the best fit - though sporadic internet connectivity is fine)
25
+
26
+
If you are building a web-based application, the LiveView approach is a super-powerful, some say "game-changing", way to build it and LiveViewJS is the best way to do it in NodeJS and Deno.
27
+
28
+
### More detail
29
+
30
+
As mentioned, a LiveView is a server-rendered HTML page that, when loaded, connects back to the server via a persistent web socket. As the user interacts with the LiveView, the client to sends user events (click, keys, etc) via the websocket back to the server and the server responds with diffs to the HTML page in return.
31
+
32
+
### Websockets and Diffs? That sounds complicated!
33
+
34
+
As a developer, you don't need to worry about connecting websockets or calculating diffs. **LiveViewJS** handles all of the complex parts of this for you. You just focus on implementing your business logic and rendering your views and LiveViewJS handles the rest.
35
+
36
+
## Example "Counter" LiveView
37
+
38
+
Here's the typical "counter" in **LiveViewJS**:
20
39
21
40
```ts
22
41
import { createLiveView, html } from"liveviewjs";
23
42
24
43
/**
25
44
* A basic counter that increments and decrements a number.
26
45
*/
27
-
exportconst counterLiveView =createLiveView<
28
-
{ count: number }, // Define LiveView Context (a.k.a state)
@@ -66,16 +82,20 @@ Yes, it "looks" like a React/Vue/Svelt UI but the main differences are:
66
82
- This page was first rendered as plain HTML (not a bundle of JS)
67
83
- The client is automatically connected to a server via a websocket
68
84
- The click events are automatically shipped to the server
69
-
- The server then runs the business logic to update the state
70
-
-Using the new state, the server then renders a new view and calculates any diffs
71
-
-Those diffs are shipped back to the client, where they are automatically applied
85
+
- The server then runs the business logic to update the state
86
+
-The server automatically calculates the minimal diffs and sends them to the client
87
+
-The client automatically applies the diffs to the DOM
72
88
73
89
Pretty cool eh? We think so too! While this counter LiveView isn't particularly useful, it gives you a quick intro to how
74
-
LiveViews work and what they look like both as code and in the browser. We've got a lot more to show you about
75
-
**LiveViewJS** including: built-in real-time / multi-player support, built-in form validation with changesets, built-in
76
-
file uploads with image previews and drag and drop support, and more!
90
+
LiveViews work and what they look like both as code and in the browser.
77
91
78
-
But first, a bit more about LiveViews...
92
+
We've got a lot more to show you about **LiveViewJS** including some amazing features built-in the framework like:
93
+
94
+
* real-time / multi-player support
95
+
* simple, powerfil form validation with changesets
96
+
* file uploads with image previews and drag and drop support, and more!
97
+
98
+
If you want more detail on LiveViews and how awesome they are feel free to keep reading. If you want to jump right in, check out the [Quick Start](../02-quick-starts/get-liveviewjs-repo.md) guide.
79
99
80
100
## LiveView is already proven technology
81
101
@@ -115,9 +135,6 @@ Here is a quote from the author and inventor of LiveView, [Chris McCord](http://
115
135
-**No client-side routing** - No need to use a library like React Router or Vue Router. LiveViews route like multi-page
116
136
applications which is handled automatically by the browser and server. (Another major complication rendered
117
137
unnecessary.)
118
-
-**No component libraries (or Storybook) required** - Traditional SPAs require teams to adopt, build or buy and then
119
-
maintain, and customize a component library and use something like [Storybook](https://storybook.js.org/). LiveView
120
-
simplifies this greatly with server-side HTML templates.
121
138
122
139
## Disadvantages
123
140
@@ -134,11 +151,3 @@ and productivity of LiveView to the NodeJS and Deno ecosystems** and are obvious
134
151
team that invented it. We believe in it so much that we think more developers should have access to the programming
Copy file name to clipboardExpand all lines: apps/liveviewjs.com/docs/01-overview/runtimes.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,10 +40,10 @@ LiveViewJS is broken up into the following packages:
40
40
-`liveviewjs`[Node](https://www.npmjs.com/package/liveviewjs) and [Deno](https://deno.land/x/liveviewjs) - The core
41
41
package that contains the **LiveViewJS** core server code. This package is runtime agnostic and can be used with
42
42
either NodeJS or Deno.
43
+
-`@liveviewjs/gen`[Link](https://www.npmjs.com/package/@liveviewjs/gen) - The code generator package that is used to
44
+
generate the LiveViewJS code including minimal project configuration for both NodeJS and Deno. This package will also add support for generating LiveViews and LiveComponents as well as other boilerplate code.
45
+
-`@liveviewjs/express`[Node](https://www.npmjs.com/package/@liveviewjs/express) - The Express package contains [ExpressJS](https://expressjs.com/) integration code and NodeJS-specific utilities like Redis pub/sub. This package is used to integrate **LiveViewJS** with Express (NodeJS). To user this packages install via `npm install @liveviewjs/express` or `yarn add @liveviewjs/express`.
46
+
-`deno`[Link](https://github.com/floodfx/liveviewjs/tree/main/packages/deno) - The Deno package contains [Oak](https://deno.land/x/oak) integration code and Deno-specific LiveViewJS utilities like BroadcastChannel pub/sub. This package is used to integrate **LiveViewJS** with Oak (Deno). To use this package, import into your Deno project via `import { LiveViewJS } from "https://raw.githubusercontent.com/floodfx/liveviewjs/main/packages/deno/mod.ts";`. (Note: DenoLand is broken for mono-repos, so we're hosting the package on GitHub for now.)
43
47
-`@liveviewjs/examples`[Node](https://www.npmjs.com/package/@liveviewjs/examples) or
44
-
[Deno](https://deno.land/x/liveviewjs/packages/examples/mod.ts) - The package contains all the example LiveViews that
45
-
can be run on either NodeJS or Deno. This package is runtime agnostic and can be used with either NodeJS or Deno.
46
-
-`@liveviewjs/express`[Node](https://www.npmjs.com/package/@liveviewjs/express) - The Express package that contains
47
-
the Express server integration code. This package is used to integrate **LiveViewJS** with Express (NodeJS).
48
-
-`https://deno.land/x/liveviewjs@VERSION/packages/deno/mod.ts` - The Deno package that contains the Oak server
49
-
integration code. This package is used to integrate **LiveViewJS** with Oak (Deno).
48
+
[Deno](https://raw.githubusercontent.com/floodfx/liveviewjs/main/packages/examples/mod.ts) - The package contains all the example LiveViews that
49
+
can be run on either NodeJS or Deno. This package is runtime agnostic and can be used with either NodeJS or Deno. See the [examples](https://github.com/floodfx/liveviewjs/tree/main/packages/examples/src/liveviews) directory for the source code.
Copy file name to clipboardExpand all lines: apps/liveviewjs.com/docs/02-quick-starts/get-liveviewjs-repo.md
+16Lines changed: 16 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,22 @@
2
2
sidebar_position: 1
3
3
---
4
4
5
+
# Let's Build a LiveView
6
+
7
+
Building a LiveView is easy with **LiveViewJS**. You can get started in just a few minutes.
8
+
9
+
## Create a New Project
10
+
11
+
**LiveViewJS** has a project generation tool that will setup the project structure and install the required dependencies for either NodeJS or Deno.
12
+
13
+
Run:
14
+
```bash
15
+
npx @liveviewjs/gen
16
+
```
17
+
18
+
You will be prompted to select the type of project you want to create and a couple other questions. Then, voilà, you will have a new project that runs out of the box!
19
+
20
+
5
21
# Download the Repo
6
22
7
23
The fastest way to run the example or build your own LiveView is by downloading the **LiveViewJS** repo. This repo
0 commit comments