alephjs / aleph.js

The Full-stack Framework in Deno.

Home Page:https://alephjs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature to prevent router redirects

ArtemSBulgakov opened this issue · comments

I use window.onbeforeunload event to prevent users from losing their form data when they try to close the page. But a user can click on <Link>, and they will be redirected to another page on the website. And there is no possibility to prevent it.

commented

you can create your own link, then handles the redirect with onClick event, aleph provides the redirect function for page navigation as SPA

Ok, will use this method. Thank you!

commented

you can get the redirect method by using useRouter hooks:

import { useRouter } from "aleph/react"

function App(){
  const { url, redirect } = useRouter()
}