0.1.4 • Published 19h ago
@fetchcore/sdk
Licence
MIT
Version
0.1.4
Deps
6
Size
146 kB
Vulns
0
Weekly
0
@fetchcore/sdk
The JavaScript/TypeScript SDK for writing FetchCore Workers.
Install
pnpm add @fetchcore/sdk
# or: npm install @fetchcore/sdk / yarn add @fetchcore/sdk
Write a Worker
import { fetchcore } from '@fetchcore/sdk';
export default fetchcore.handler(async (ctx, input) => {
const browser = await ctx.launchBrowser({ behavior: 'human' });
const page = await browser.newPage();
await page.goto(input.url);
await ctx.results.push({ url: input.url, title: await page.title() });
});
ctx.launchBrowser() returns a BrowserContext (an isolated browser identity)
with a Playwright-compatible API — call .newPage() on it. The underlying
stealth engine is an implementation detail — user code doesn't tie itself to a
specific engine. When a proxy is configured, locale and timezone are matched to
the proxy's exit IP automatically.
All framework capabilities arrive via the injected ctx object: ctx.results
/ ctx.state / ctx.queue for storage, ctx.log for structured logging,
ctx.launchBrowser() for stealth browsing.
Local vs platform mode
The same handler runs unchanged in two modes:
- Local mode (default): storage on local filesystem, browser on your machine. Use this for development.
- Platform mode (
FC_IS_AT_HOME=1): storage and browser managed by the FetchCore platform. The switch is one env var; no code changes.
License
MIT