![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
@mrdotb/live-react
Advanced tools
[![Hex.pm](https://img.shields.io/hexpm/v/live_react.svg)](https://hex.pm/packages/live_react) [![Hexdocs.pm](https://img.shields.io/badge/docs-hexdocs.pm-purple)](https://hexdocs.pm/live_react) [![GitHub](https://img.shields.io/github/stars/mrdotb/live_r
React inside Phoenix LiveView.
Phoenix LiveView enables rich, real-time user experiences with server-rendered HTML. It works by communicating any state changes through a websocket and updating the DOM in realtime. You can get a really good user experience without ever needing to write any client side code.
LiveReact builds on top of Phoenix LiveView to allow for easy client side state management while still allowing for communication over the websocket.
live_react
to your list of dependencies in mix.exs
:def deps do
[
{:live_react, "~> 0.2.0-rc.0"}
]
end
setup
in mix.exs
:defp aliases do
[
setup: ["deps.get", "assets.setup", "npm install --prefix assets", "assets.build"],
]
end
defp aliases do
[
setup: ["deps.get", "assets.setup", "cmd --cd assets npm install", "assets.build"],
]
end
mix deps.get
import LiveReact
in html_helpers/0
inside /lib/<app_name>_web.ex
like so:# /lib/<app_name>_web.ex
defp html_helpers do
quote do
# ...
import LiveReact # <-- Add this line
# ...
end
end
assets/package.json
{
"dependencies": {
"@mrdotb/live-react": "^0.2.1-beta",
"phoenix": "file:../deps/phoenix",
"phoenix_html": "file:../deps/phoenix_html",
"phoenix_live_view": "file:../deps/phoenix_live_view",
"react": "^18.3.1",
"react-dom": "^18.3.1"
}
}
react
directory inside assets
and add a index.js
file// import and export the react components you want to use in your LiveView
// ex: import { Simple } from "./simple";
// ex: export default { Simple };
export default {};
assets/js/app.js
file...
import components from "../react";
import { getHooks } from "@mrdotb/live-react";
const hooks = {
...getHooks(components),
};
let csrfToken = document
.querySelector("meta[name='csrf-token']")
.getAttribute("content");
let liveSocket = new LiveSocket("/live", Socket, {
hooks: hooks, // <-- pass the hooks
longPollFallbackMs: 2500,
params: { _csrf_token: csrfToken },
});
...
content
in the assets/tailwind.config.js
filecontent: [
...
"./react/**/*.jsx", // <- if you are using jsx
"./react/**/*.tsx" // <- if you are using tsx
],
Check out the demo website on fly.io to see some examples of what you can do with LiveReact.
I was inspired by the following libraries:
I had a need for a similar library for React and so I created LiveReact 👍
FAQs
[![Hex.pm](https://img.shields.io/hexpm/v/live_react.svg)](https://hex.pm/packages/live_react) [![Hexdocs.pm](https://img.shields.io/badge/docs-hexdocs.pm-purple)](https://hexdocs.pm/live_react) [![GitHub](https://img.shields.io/github/stars/mrdotb/live_r
The npm package @mrdotb/live-react receives a total of 7 weekly downloads. As such, @mrdotb/live-react popularity was classified as not popular.
We found that @mrdotb/live-react demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.