5
61%
MIT
Reason / BuckleScript bindings for React Helmet, a document head manager for React

@moox/bs-react-helmet

Reason / BuckleScript bindings for React Helmet, a document head manager for React.

Install

yarn add react-helmet @moox/bs-react-helmet

Note that you need react, react-dom, reason-react and react-helmet as peer dependencies.

Adjust your bsconfig.js by adding this package:

  "bs-dependencies": [
    "reason-react",
    "@moox/bs-react-helmet"
  ]

Usage

  • RE
  • ML
let component = ReasonReact.statelessComponent("CommonThings");

let make = (_) => {
  ...component,
  render: _self =>
    <BsReactHelmet defaultTitle="This is a title">
      <style>
        (
          {j|
html {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", sans-serif;
}
|j}
          |> ReasonReact.string
        )
      </style>
    </BsReactHelmet>
};
let component = ReasonReact.statelessComponent "CommonThings"
let make _ =
  {
    component with
    render =
      (fun _self  ->
         ((BsReactHelmet.createElement ~defaultTitle:"This is a title"
             ~children:[((style
                            ~children:[{j|
html {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", sans-serif;
}
|j}
                                         |> ReasonReact.string] ())[@JSX ])]
             ())[@JSX ]))
  }

Server-side static rendering

  • RE
  • ML
let helmet = BsReactHelmet.renderStatic();
let title = helmet##title##toString();
let helmet = BsReactHelmet.renderStatic ()
let title = (## (## helmet title) toString) ()

Follow official documentation for all methods available.


CHANGELOG

LICENSE