Skip to content

Instantly share code, notes, and snippets.

@disinfeqt
Created December 29, 2023 08:09
Show Gist options
  • Save disinfeqt/59f8ac56d6ac7aa2e9f910653dfa6f73 to your computer and use it in GitHub Desktop.
Save disinfeqt/59f8ac56d6ac7aa2e9f910653dfa6f73 to your computer and use it in GitHub Desktop.
Framer Redirect Override
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} />
}
}
@disinfeqt
Copy link
Author

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).

  1. Customize cookie name and redirect URL
  2. Add to Framer as a New override
  3. Select Desktop and choose Override withRedirect

Created by @limichange

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment