Use React template into your Elixir application for server rendering
Reaxt is a library that allows you to integrate your React components into your Elixir application. It provides an isomorphic environment, meaning that your application can work seamlessly with both server-side Elixir and client-side JavaScript. With Reaxt, you can use any JavaScript compiled language and any JavaScript routing logic or library. It offers a nice development workflow with combined stacktrace, hot reloading, and an NPM/Webpack configuration. Reaxt also provides a user interface to view your compiled JavaScript application.
mix.exs file and your application config.defp deps do
[
{:reaxt, "~> 1.0"}
]
end
def application do
[
applications: [:reaxt]
]
end
:reaxtWebpack instead of :reaxt_webpack.def project do
[
...
compilers: [:reaxt_webpack | Mix.compilers(Mix.env)],
...
]
end
config.exs file, link the Reaxt application to your application containing the JavaScript web app.config :reaxt, :otp_app, :yourapp
web directory at the root of your project (MIXROOT/web).web directory, create a package.json file containing your app’s NPM dependencies.web directory, create a webpack.config.js file containing only the client-side logic. Use “reaxt/style” instead of “style” loader to load your CSS. A typical output path is ../priv/static.web directory, create a components directory containing modules that export your React components.WebPack.header in the <head> section./your/public/path/<%= WebPack.file_of(:entry_name) %> to include the JavaScript generated by Webpack.html, css, and js_render keys. You need to add the following to your HTML:<style><%= render.css %></style><div id="myblockid"><%= render.html %></div><script><%= render.js_render %>("myblockid")</script>Reaxt is a library that allows you to seamlessly integrate React components into your Elixir application. With its isomorphic environment, you can use both server-side Elixir and client-side JavaScript to build your application. Reaxt provides a range of features including isomorphic compatibility, support for various JavaScript languages and routing logic, a fluent development workflow, and an easy installation process. By following the provided installation guide, you can quickly start using Reaxt in your Elixir application.