Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Rich, real-time user experiences with server-rendered HTML

License

NotificationsYou must be signed in to change notification settings

rmand97/phoenix_live_view

 
 

Repository files navigation

Actions StatusHex.pmDocumentation

Phoenix LiveView enables rich, real-time user experiences with server-rendered HTML.

Visit thehttps://livebeats.fly.dev demo to seethe kinds of applications you can build, or see a sneak peek below:

Phoenix.LiveView.LiveBeats.Demo.mp4

LiveView ships by default in new Phoenix applications. After youinstall Elixir on your machine,you can create your first LiveView app in two steps:

$ mix archive.install hex phx_new$ mix phx.new demo

If you have an older existing Phoenix app and you wish to add LiveView,seethe previous installation guide.

Feature highlights

LiveView brings a unified experience to building web applications. You no longerhave to split work between client and server, across different toolings, layers, andabstractions. Instead, LiveView enriches the server with a declarative and powerfulmodel while keeping your code closer to your data (and ultimately your source of truth):

  • Declarative rendering: Render HTML on the server over WebSockets with a declarative model, including an optional LongPolling fallback.

  • Rich templating language: Enjoy HEEx: a templating language that supports function components, slots, HTML validation, verified routes, and more.

  • Diffs over the wire: Instead of sending "HTML over the wire", LiveView knows exactly which parts of your templates change, sending minimal diffs over the wire after the initial render, reducing latency and bandwidth usage. The client leverages this information and optimizes the browser with 5-10x faster updates, compared to solutions that replace whole HTML fragments.

  • Live form validation: LiveView supports real-time form validation out of the box. Create rich user interfaces with features like uploads, nested inputs, andspecialized recovery.

  • File uploads: Real-time file uploads with progress indicators and image previews. Process your uploads on the fly or submit them to your desired cloud service.

  • Rich integration API: Use the rich integration API to interact with the client, withphx-click,phx-focus,phx-blur,phx-submit, andphx-hook included for cases where you have to write JavaScript.

  • Optimistic updates and transitions: Perform optimistic updates and transitions with JavaScript commands viaPhoenix.LiveView.JS.

  • Loose coupling: Reuse more code via stateful components with loosely-coupled templates, state, and event handling — a must for enterprise application development.

  • Live navigation: Enriched links and redirects are just more ways LiveView keeps your app light and performant. Clients load the minimum amount of content needed as users navigate around your app without any compromise in user experience.

  • Latency simulator: Emulate how slow clients will interact with your application with the latency simulator.

  • Robust test suite: Write tests with confidence alongside Phoenix LiveView built-in testing tools. No more running a whole browser alongside your tests.

Learning

Check ourcomprehensive docs to get started.

The Phoenix framework documentation also keeps a list ofcommunity resources, including books, videos, and other materials, and some include LiveView too.

Also follow these announcements from the Phoenix team on LiveView for more examples and rationale:

Component systems

When you create a new Phoenix project, it comes with a minimal component system to power Phoenix generators.In case you want to enrich your developer experience, there are several component systems provided by thecommunity at different stages of development:

  • Bloom: The opinionated, open-source extension to Phoenix Core Components

  • Doggo: Headless UI components for Phoenix

  • Petal Components: Phoenix + Live View HEEX Components

  • PrimerLive: An implementation of GitHub's Primer Design System using Phoenix LiveView

  • SaladUI: Phoenix Liveview component library inspired by shadcn UI

  • Mishka Chelekom: Phoenix + LiveView UI kit and HEEx components

  • Fluxon UI: Elegant and accessible UI components for Phoenix LiveView

What makes LiveView unique?

LiveView is server-centric. You no longer have to worry about managingboth client and server to keep things in sync. LiveView automaticallyupdates the client as changes happen on the server.

LiveView is first rendered statically as part of regular HTTP requests,which provides quick times for "First Meaningful Paint", in addition tohelping search and indexing engines.

Then LiveView uses a persistent connection between client and server.This allows LiveView applications to react faster to user events asthere is less work to be done and less data to be sent compared tostateless requests that have to authenticate, decode, load, and encodedata on every request.

When LiveView was first announced, many developers from differentbackgrounds got inspired by the potential unlocked by LiveView tobuild rich, real-time user experiences. We believe LiveView is builton top of a solid foundation that makes LiveView hard to replicateanywhere else:

  • LiveView is built on top of the Elixir programming language andfunctional programming, which provides a great model for reasoningabout your code and how your LiveView changes over time.

  • By building on top of ascalable platform,LiveView scales well vertically (from small to large instances)and horizontally (by adding more instances). This allows you tocontinue shipping features when more and more users join yourapplication, instead of dealing with performance issues.

  • LiveView applications aredistributed and real-time. A LiveViewapp can push events to users as those events happen anywhere inthe system. Do you want to notify a user that their best friendjust connected? This is easily done without a single line ofcustom JavaScript and with no extra external dependencies(no extra databases, no Redis, no extra message queues, etc.).

  • LiveView performs change tracking: whenever you change a value onthe server, LiveView will send to the client only the values thatchanged, drastically reducing the latency and the amount of datasent over the wire. This is achievable thanks to Elixir'simmutability and its ability to treat code as data.

Browser Support

All current Chrome, Safari, Firefox, and MS Edge are supported.IE11 support is available with the following polyfills:

$ npm install --save --prefix assets mdn-polyfills url-search-params-polyfill formdata-polyfill child-replace-with-polyfill classlist-polyfill new-event-polyfill @webcomponents/template shim-keyboard-event-key core-js

Note: Theshim-keyboard-event-key polyfill is also required forMS Edge 12-18.

Note: Theevent-submitter-polyfill package is also required forMS Edge 12-80 & Safari < 15.4.

// assets/js/app.jsimport"mdn-polyfills/Object.assign"import"mdn-polyfills/CustomEvent"import"mdn-polyfills/String.prototype.startsWith"import"mdn-polyfills/Array.from"import"mdn-polyfills/Array.prototype.find"import"mdn-polyfills/Array.prototype.some"import"mdn-polyfills/NodeList.prototype.forEach"import"mdn-polyfills/Element.prototype.closest"import"mdn-polyfills/Element.prototype.matches"import"mdn-polyfills/Node.prototype.remove"import"child-replace-with-polyfill"import"url-search-params-polyfill"import"formdata-polyfill"import"classlist-polyfill"import"new-event-polyfill"import"@webcomponents/template"import"shim-keyboard-event-key"import"event-submitter-polyfill"import"core-js/features/set"import"core-js/features/url"import{Socket}from"phoenix"import{LiveSocket}from"phoenix_live_view"...

Contributing

We appreciate any contribution to LiveView.

Please see the PhoenixCode of Conduct andContributing guides.

Running the Elixir tests:

$ mix deps.get$ mixtest

Running all JavaScript tests:

$ npm run setup$ npm runtest

Running the JavaScript unit tests:

$ npm run setup$ npm run js:test# to automatically run tests for files that have been changed$ npm run js:test.watch

Running the JavaScript end-to-end tests:

$ npm run setup$ npm run e2e:test

Checking test coverage:

$ npm run cover$ npm run cover:report

JS contributions are very welcome, but please do not include an updatedpriv/static/phoenix_live_view.js in pull requests. The maintainers will update it as part of the release process.

About

Rich, real-time user experiences with server-rendered HTML

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Elixir62.0%
  • JavaScript38.0%

[8]ページ先頭

©2009-2025 Movatter.jp