What is Feliz?
mainFeliz is a React DSL (Domain Specific Language) for F# designed to build React applications with a focus on developer experience and type safety. It provides a fresh, optimized way to write React components using F# syntax while maintaining full compatibility with the React API (hooks, context, etc.).
module App
open Feliz
[<ReactComponent>]
let Counter() =
let (count, setCount) = React.useState(0)
Html.div [
Html.button [
prop.style [ style.marginRight 5 ]
prop.onClick (fun _ -> setCount(count + 1))
prop.text "Increment"
]
Html.button [
prop.style [ style.marginLeft 5 ]
prop.onClick (fun _ -> setCount(count - 1))
prop.text "Decrement"
]
Html.h1 count
]
open Browser.Dom
let root = ReactDOM.createRoot (document.getElementById "root")
root.render (Counter())