Prerequisites
- Next.js 14+ with the App Router
- Node.js 18+
- A Geekflare API key — get one free
Installation
- pnpm
- npm
- yarn
Set your API key
Add your API key to.env.local:
.env.local
Shared client
Create a single client instance to reuse across your app:lib/geekflare.ts
Web Scraping
Route Handler
Accepts a POST request from your client-side code and returns scraped content.app/api/scrape/route.ts
Server Action
Use directly from Client Components without a round-trip to a route:app/actions.ts
Server Component
Fetch and render scraped content directly in a Server Component:app/scrape/page.tsx
Search
Route Handler
app/api/search/route.ts
Server Action
app/actions.ts
Server Component
app/search/page.tsx
Screenshot
Route Handler
app/api/screenshot/route.ts
Server Component
Render the screenshot directly in a page usingnext/image:
app/preview/page.tsx
Error handling
Handle errors consistently across Route Handlers and Server Actions.Common error codes
Route Handler pattern
Server Action pattern
Next steps
- NestJS quickstart — Injectable services and modules
- API Reference — Full endpoint documentation
- SDK on npm