Forest.js Core Documentation - v1.2.3
    Preparing search index...

    Function createForest

    • Function

      createForest

      Type Parameters

      • T extends HTMLElement

        Type of the root element

      Parameters

      Returns null | HTMLHtmlElement | T

      The decorated DOM element.

      Create a Forest app

      const { routerStore } = createRouter();

      const app = createForest((body) => addChild({ routerStore }, ({ routerStore }) => {
      if (routerStore?.path === "/") {
      return import("./pages/home");
      }
      if (routerStore?.path === "/about") {
      return import("./pages/about");
      }
      if (routerStore?.path === "/404") {
      return import("./pages/404");
      }
      return import("./pages/404");
      })(body));