an app to share curated trails sidetrail.app
atproto nextjs react rsc
50
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 31 lines 730 B view raw
1"use client"; 2 3import { useRouter } from "next/navigation"; 4import "./BackButton.css"; 5 6type Props = { 7 fallbackPath?: string; 8 variant?: "default" | "top"; 9 className?: string; 10}; 11 12export function BackButton({ fallbackPath = "/", variant = "default", className }: Props) { 13 const router = useRouter(); 14 15 const handleBack = () => { 16 if (window.history.state && window.history.length > 1) { 17 router.back(); 18 } else { 19 router.push(fallbackPath); 20 } 21 }; 22 23 const variantClass = variant === "top" ? "BackButton-top" : ""; 24 const classes = ["BackButton", variantClass, className].filter(Boolean).join(" "); 25 26 return ( 27 <button onClick={handleBack} className={classes}> 28 back 29 </button> 30 ); 31}