Warning: Reason support is experimental. We are looking for beta-tester and contributors.

How to make the client side program get an HTML element from the server and insert it in the page?

A very convenient way to do that is to use RPCs :

let%rpc get_mydiv (() : unit) : _ Lwt.t = div [ ... ]
[%client
  ...
  let%lwt mydiv = get_mydiv () in
  Dom.appendChild parent (To_dom.of_element mydiv)
  ...
]

Server functions take exactly one parameter.

RPCs are just syntactic sugar for pathless services returning OCaml values.

The type of the function parameter must have been declared with the JSON module of ppx_deriving (which needs to be manually installed). This enables server-side data validation.

example:

type t = int * string [@@deriving json]