import { Suspense } from "react"; import { lazyWithRetry } from "./lib/lazyWithRetry"; import { HashRouter, Navigate, Route, Routes } from "react-router-dom"; import { ScrollToTop } from "./components/ScrollToTop"; import { BECOME_ROLES } from "./lib/becomeRoles"; import { DeepLinkHandler } from "./components/DeepLinkHandler"; import { RouteErrorBoundary } from "./components/RouteErrorBoundary"; // The map is the homepage, but lazy-loading it keeps its chunk (plus the // IndexedDB offline-cache layer) out of the initial entry bundle. const MapPage = lazyWithRetry(() => import("./pages/MapPage")); // Lazy load everything else — each page becomes its own JS chunk const Index = lazyWithRetry(() => import("./pages/Index")); const EventsPage = lazyWithRetry(() => import("./pages/EventsPage")); const LabPage = lazyWithRetry(() => import("./pages/LabPage")); const WalletPage = lazyWithRetry(() => import("./pages/WalletPage")); const MintsPage = lazyWithRetry(() => import("./pages/MintsPage")); const SettingsPage = lazyWithRetry(() => import("./pages/SettingsPage")); const CreateSpotPage = lazyWithRetry(() => import("./pages/CreateSpotPage")); const CreateShopPage = lazyWithRetry(() => import("./pages/CreateShopPage")); const CreateEventPage = lazyWithRetry(() => import("./pages/CreateEventPage")); const CreateListingPage = lazyWithRetry(() => import("./pages/CreateListingPage")); const CreateTourPage = lazyWithRetry(() => import("./pages/CreateTourPage")); const EditSpotPage = lazyWithRetry(() => import("./pages/EditSpotPage")); const EditShopPage = lazyWithRetry(() => import("./pages/EditShopPage")); const EditEventPage = lazyWithRetry(() => import("./pages/EditEventPage")); const EditTourPage = lazyWithRetry(() => import("./pages/EditTourPage")); const GearSwapPage = lazyWithRetry(() => import("./pages/GearSwapPage")); const ListingDetailPage = lazyWithRetry(() => import("./pages/ListingDetailPage")); const TradesPage = lazyWithRetry(() => import("./pages/TradesPage")); const SpotDetailPage = lazyWithRetry(() => import("./pages/SpotDetailPage")); const ShopDetailPage = lazyWithRetry(() => import("./pages/ShopDetailPage")); const EventDetailPage = lazyWithRetry(() => import("./pages/EventDetailPage")); const OnboardingPage = lazyWithRetry(() => import("./pages/OnboardingPage")); const PyramidPage = lazyWithRetry(() => import("./pages/PyramidPage")); // All "become a " flows now share a single param route backed by a role // registry (see src/lib/becomeRoles.tsx) instead of 12 separate route lines. const BecomeRolePage = lazyWithRetry(() => import("./pages/BecomeRolePage")); const SkatersPage = lazyWithRetry(() => import("./pages/SkatersPage")); const CrewsPage = lazyWithRetry(() => import("./pages/CrewsPage")); const CreateCrewPage = lazyWithRetry(() => import("./pages/CreateCrewPage")); const EditCrewPage = lazyWithRetry(() => import("./pages/EditCrewPage")); const CrewDetailPage = lazyWithRetry(() => import("./pages/CrewDetailPage")); const CoachDetailPage = lazyWithRetry(() => import("./pages/CoachDetailPage")); const TourDetailPage = lazyWithRetry(() => import("./pages/TourDetailPage")); const AboutPage = lazyWithRetry(() => import("./pages/AboutPage")); const FAQPage = lazyWithRetry(() => import("./pages/FAQPage")); const FoodPage = lazyWithRetry(() => import("./pages/FoodPage")); const CommunityStatsPage = lazyWithRetry(() => import("./pages/CommunityStatsPage")); const SpotCollectionsPage = lazyWithRetry(() => import("./pages/SpotCollectionsPage")); const CollectionDetailPage = lazyWithRetry(() => import("./pages/CollectionDetailPage")); const DirectMessagesPage = lazyWithRetry(() => import("./pages/DirectMessagesPage")); const ConversationPage = lazyWithRetry(() => import("./pages/ConversationPage")); const GroupConversationPage = lazyWithRetry(() => import("./pages/GroupConversationPage")); const ContactsPage = lazyWithRetry(() => import("./pages/ContactsPage")); const BountyLeaderboardPage = lazyWithRetry(() => import("./pages/BountyLeaderboardPage")); const ZapLeaderboardPage = lazyWithRetry(() => import("./pages/ZapLeaderboardPage")); const SignersPage = lazyWithRetry(() => import("./pages/SignersPage")); const StashPage = lazyWithRetry(() => import("./pages/StashPage")); const NIP19Page = lazyWithRetry(() => import("./pages/NIP19Page").then(m => ({ default: m.NIP19Page }))); const LicensePage = lazyWithRetry(() => import("./pages/LicensePage")); const PrivacyPage = lazyWithRetry(() => import("./pages/PrivacyPage")); const SupportersPage = lazyWithRetry(() => import("./pages/SupportersPage")); const RiderCardPage = lazyWithRetry(() => import("./pages/RiderCardPage")); const AmberCallbackPage = lazyWithRetry(() => import("./pages/AmberCallbackPage")); const MarketplacePage = lazyWithRetry(() => import("./pages/MarketplacePage")); const NewsletterPage = lazyWithRetry(() => import("./pages/NewsletterPage")); const GlossaryPage = lazyWithRetry(() => import("./pages/GlossaryPage")); const NotFound = lazyWithRetry(() => import("./pages/NotFound")); // Minimal inline fallback — no extra component needed function PageLoader() { return (
); } // Legacy `/become-` URLs are linked from many pages and may be // bookmarked/shared, so each redirects to the unified `/become/` route. const BECOME_SLUGS = Object.keys(BECOME_ROLES); export function AppRouter() { return ( {/* Per-route boundary: a crash in one page shows a recoverable message instead of blanking the whole app. Resets automatically on navigate (keyed by pathname inside RouteErrorBoundary). */} }> {/* Map is the homepage */} } /> {/* /map redirects to / */} } /> {/* Legacy home page still accessible */} } /> } /> } /> {/* Legacy route redirect */} } /> {/* Unified role route + legacy /become- redirects */} } /> {BECOME_SLUGS.map((slug) => ( } /> ))} } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> {/* Bounty System */} } /> {/* Zap Leaderboards */} } /> {/* Security & Signers */} } /> {/* Stash - Private Inventory */} } /> {/* Info pages */} } /> } /> } /> } /> {/* Amber NIP-55 callback — Amber redirects here after signing/login */} } /> {/* Marketplace */} } /> {/* Newsletter */} } /> {/* Trick Glossary */} } /> {/* NIP-19 route for npub1, note1, naddr1, nevent1, nprofile1 */} } /> {/* ADD ALL CUSTOM ROUTES ABOVE THE CATCH-ALL "*" ROUTE */} } /> ); } export default AppRouter;