Created
December 29, 2023 08:09
-
-
Save disinfeqt/59f8ac56d6ac7aa2e9f910653dfa6f73 to your computer and use it in GitHub Desktop.
Framer Redirect Override
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import type { ComponentType } from "react" | |
import queryString from "query-string" | |
import Cookies from "js-cookie" | |
export function withRedirect(Component): ComponentType { | |
if (typeof window !== "undefined") { | |
const idToken = Cookies.get("AuthID") | |
const parsed = queryString.parse(window.location.search) | |
if (idToken && typeof parsed.home === "undefined") { | |
window.location.replace("https://app.domain.tld") | |
return | |
} | |
} | |
return (props) => { | |
return <Component {...props} /> | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This override will detect if the user is authenticated and skip the marketing site and redirect to the app.
It also allows the user to visit the marketing site by adding
/?home
(similar behavior on https://height.app/?home).withRedirect
Created by @limichange