@contentstech/stackflow-plugin-history-sync
TypeScript icon, indicating that this package has built-in type declarations

0.10.0 • Public • Published

@stackflow/plugin-history-sync

Synchronizes the stack state with the current browser's history

Usage

import { stackflow } from "@stackflow/react";
import { historySyncPlugin } from "@stackflow/plugin-history-sync";
import { MyHome } from "./MyHome";
import { MyArticle } from "./MyArticle";
import { NotFoundPage } from "./NotFoundPage";

const { Stack, useFlow } = stackflow({
  activities: {
    MyHome,
    MyArticle,
    NotFoundPage,
  },
  plugins: [
    // ...
    historySyncPlugin({
      routes: {
        /**
         * You can link the registered activity with the URL template.
         */
        MyHome: "/",
        MyArticle: "/articles/:articleId",
        NotFoundPage: "/404",
      },
      /**
       * If a URL that does not correspond to the URL template is given, it moves to the `fallbackActivity`.
       */
      fallbackActivity: ({ context }) => "NotFoundPage",
      /**
       * Uses the hash portion of the URL (i.e. window.location.hash)
       */
      useHash: false,
    }),
  ],
});

Readme

Keywords

none

Package Sidebar

Install

npm i @contentstech/stackflow-plugin-history-sync

Weekly Downloads

5

Version

0.10.0

License

MIT

Unpacked Size

742 kB

Total Files

150

Last publish

Collaborators

  • xiniha