Neon’s Context.dev template includes web search and scraping, with optional Answers, Brand Retrieval, and News Search routes. Extend the generated function to call any other Context API.
The current Neon CLI, which includes neon functions new
If your CLI does not recognize the registry commands, update it:
npm install -g neon@latest
From your application root, link the project and branch you want to use:
neon link --project-id YOUR_PROJECT_ID --branch YOUR_BRANCH --no-env-pull
Create the function
Run this from your application root:
neon functions new context-dev --yes
This creates functions/contextdev/index.ts and adds it to neon.ts. The default routes are /web-search and /web-scrape.To include all five routes, use this command instead when creating the function:
neon functions new context-dev --all-operations --yes
To choose specific routes, repeat --operation with each route name instead:
neon functions new context-dev --operation web-search --operation web-answers --yes
The route names are web-search, web-scrape, web-answers, brand-retrieve, and news-search.
Configure authentication
Set these values in an uncommitted .env.local file:
Generate CONTEXT_FUNCTION_TOKEN with openssl rand -hex 32. It must be at least 32 characters.
The API key lets the function call Context.dev; the caller token controls access to your function. Keep both server-side and add .env.local to .gitignore.
Run and call the function
Start the function locally:
neon dev --env .env.local --source ./functions/contextdev/index.ts --port 3001
In a second terminal, set CONTEXT_FUNCTION_TOKEN to the same caller token from .env.local, then send a request:
The response contains results with source URLs. Calls use your Context.dev credits.
Deploy the function
Review neon.ts, then deploy to the linked branch with both secrets:
neon deploy --env .env.local --no-env-pull
This applies all services declared in neon.ts to the linked branch. Replace http://localhost:3001 in the request above with the printed function URL, keeping /web-search and the bearer header.