A Next.js prediction markets platform to Know your Odds, powered by Polymarket.
- β Wallet Connection - Reown AppKit with multi-wallet support (MetaMask, WalletConnect, etc.)
- β Real-time Market Data - Live prediction markets from Polymarket Gamma API
- β Dynamic Home Page - Trending, Breaking, and New events with instant switching
- β Category Browse - Explore by Politics, Sports, Finance, Crypto, and more
- β Event Details - View grouped markets with volume and liquidity stats
- β Market Trading - Individual market pages with price charts
- β Responsive Design - Beautiful UI with Shadcn components and Framer Motion
- β Type Safe - Full TypeScript support with Zod validation
- β Optimized Performance - TanStack Query caching and parallel data fetching
- β Cloudflare Workers - Edge deployment for global performance
- Node.js 18+
- pnpm (recommended) or npm/yarn
- Reown Cloud Project for AppKit
pnpm installCreate a .env.local file:
# Reown AppKit
NEXT_PUBLIC_REOWN_PROJECT_ID=your_project_id_here
# Optional: Polymarket Builder API (for order attribution - future feature)
# POLY_BUILDER_API_KEY=your_builder_api_key
# POLY_BUILDER_SECRET=your_builder_secret
# POLY_BUILDER_PASSPHRASE=your_builder_passphraseGet your Reown Project ID:
- Go to https://cloud.reown.com/
- Create a new project
- Copy your Project ID
pnpm devOpen http://localhost:8000 in your browser.
pnpm build- User lands on home page
- Sees Trending events by default (highest volume markets)
- Can switch to Breaking (last 7 days) or New (today's events)
- Can browse All Categories (Politics, Sports, Finance, etc.)
- Click a category from navbar or home page
- View all markets in that category (e.g., Sports)
- Markets fetched using tag-based filtering
- Click any event card
- See event details, stats, and all related markets
- Click a market to view trading interface
- View market question and description
- See price chart with historical data
- View outcome prices and volume
- Trading interface (coming soon)
- Next.js 15 - App Router with React Server Components
- Reown AppKit - Wallet connection and authentication
- Wagmi - React hooks for Ethereum
- Viem - Low-level Ethereum interface
- TanStack Query - Data fetching, caching, and state management
- Shadcn UI - Beautiful, accessible components
- Framer Motion - Smooth animations and transitions
- Tailwind CSS v4 - Utility-first styling
- BiomeJS - Fast linter and formatter
User β Reown AppKit β Wagmi β Knoww API Routes β Polymarket Gamma API
-
Trending Events -
/api/events/trending- Fetches high-volume events
- Sorted by volume descending
-
New Events -
/api/events/new- Fetches events created today
- Dynamic date calculation
-
Breaking Events -
/api/events/breaking- Fetches recent high-volume events (last 7 days)
- Ideal for breaking news markets
-
Category Markets -
/api/markets/by-tag- 2-step process: Slug β Tag ID β Markets
- Efficient filtering by category
-
Event Detail -
/api/events/[id]- Full event data with all markets
-
Market Detail -
/api/markets/[id]- Individual market trading data
knoww/
βββ src/
β βββ app/
β β βββ api/ # Next.js API routes
β β β βββ events/ # Event endpoints
β β β βββ markets/ # Market endpoints
β β β βββ tags/ # Category endpoints
β β β βββ orders/ # Order management (future)
β β β βββ wallet/ # Wallet queries (future)
β β β
β β βββ events/
β β β βββ [tag]/ # Category page
β β β βββ detail/[id]/ # Event detail
β β β
β β βββ markets/[slug]/ # Market detail
β β βββ page.tsx # Home page
β β βββ layout.tsx # Root layout
β β
β βββ hooks/ # TanStack Query hooks
β β βββ use-trending-events.ts
β β βββ use-new-events.ts
β β βββ use-breaking-events.ts
β β βββ use-tags.ts
β β βββ use-tag-details.ts
β β βββ use-markets-by-tag.ts
β β βββ use-event-detail.ts
β β βββ use-market-by-id.ts
β β βββ use-market-detail.ts
β β
β βββ components/
β β βββ navbar.tsx # Main navigation
β β βββ market-price-chart.tsx
β β βββ ui/ # Shadcn components
β β
β βββ lib/
β β βββ constants.ts # API endpoints
β β βββ polymarket.ts # Utilities
β β
β βββ config/
β β βββ index.tsx # Reown AppKit config
β β
β βββ context/
β βββ index.tsx # Providers (AppKit, TanStack Query)
β
βββ public/
βββ FLOW_DIAGRAM.md # Visual architecture guide
βββ README.md # This file
βββ package.json
βββ next.config.ts # Next.js config (Turbopack dev, Webpack prod)
βββ tsconfig.json
βββ biome.json # Linter config
- Dynamic Views: Trending (default), Breaking, New, All Categories
- Instant Switching: Pre-fetched data for zero-delay transitions
- Event Cards: Images, volume, market count, hover animations
- Responsive Grid: 1-3 columns based on screen size
- Navbar: Category links, wallet connection, account dropdown
- Smart Back Buttons: Use browser history (
router.back()) - Breadcrumbs: Clear navigation hierarchy
- Skeleton Loaders: Match actual content layout
- Staggered Animations: Cards fade in with 50ms delays
- Progress Indicators: Loading spinners for async operations
- Framer Motion: Smooth page transitions
- Hover Effects: Cards lift and scale on hover
- Fade Ins: Content appears with opacity transitions
- No Private Keys - Users control their own wallets
- Client-Side Signing - All transactions signed in browser
- Reown AppKit - Secure wallet connection protocol
NEXT_PUBLIC_*- Exposed to browser (safe for client-side)- Server-only vars - Never exposed to client
- Install Wrangler CLI
pnpm install -g wrangler- Login to Cloudflare
wrangler login- Configure
wrangler.toml
name = "knoww"
compatibility_date = "2024-01-01"
pages_build_output_dir = ".vercel/output/static"
[env.production]
vars = { ENVIRONMENT = "production" }- Deploy
pnpm run deploySet in Cloudflare Workers dashboard:
NEXT_PUBLIC_REOWN_PROJECT_IDPOLY_BUILDER_API_KEY(optional, for future trading)POLY_BUILDER_SECRET(optional)POLY_BUILDER_PASSPHRASE(optional)
- Parallel Data Fetching - All event types load simultaneously
- TanStack Query Caching - 1-minute stale time, prevents redundant calls
- Direct ID Fetching - Market pages use IDs for 1 API call vs 2
- Server-Side Caching - 60-second cache on API routes
- Code Splitting - Automatic by Next.js App Router
- Edge Deployment - Cloudflare Workers for global performance
pnpm dev # Start dev server (Turbopack)
pnpm build # Build for production
pnpm start # Start production server
pnpm lint # Run BiomeJS linter
pnpm format # Format code with BiomeJS
pnpm type-check # Check TypeScript types- BiomeJS - Fast linter and formatter
- TypeScript - Strict mode enabled
- Tailwind CSS - Utility-first styling
- Component Structure - Server components by default, client only when needed
# Add Shadcn component
pnpm dlx shadcn@latest add button- FLOW_DIAGRAM.md - Visual architecture and user flow
- Polymarket Docs - Official Polymarket API docs
- Reown Docs - Reown AppKit documentation
- Next.js Docs - Next.js documentation
- TanStack Query Docs - Data fetching documentation
Tags (Categories)
β
Events (Grouped Questions)
β
Markets (Individual Tradeable Questions)
Example:
Tag: "Sports" (slug: sports, id: 1)
β
Event: "Super Bowl Champion 2026" (id: 23656)
β
Market: "Will the Buffalo Bills win Super Bowl 2026?" (id: 540208)
- β Wallet connection via Reown AppKit
- β Browse markets by category
- β View event details
- β View market details with charts
- β Trending, Breaking, New event feeds
- π Trading Interface - Buy/Sell orders with wallet integration
- π Order Management - View and cancel open orders
- π Portfolio View - Track positions and P&L
- π Real-time Updates - WebSocket integration
- π Search & Filters - Find specific markets
- π Notifications - Market alerts and updates
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch
- Make your changes
- Run
pnpm lintand fix any errors - Submit a pull request
MIT
- Polymarket - Prediction market platform
- Reown - Wallet connection infrastructure
- Shadcn - Component library
- TanStack - Query and state management
- Cloudflare - Edge deployment platform
Built with β€οΈ by the Soclly team