NexoFlow
Docs · nexoflow-sdk SDK overview & install

Technical SEOOfficial npm package · v0.3.8

nexoflow-sdk

The official TypeScript SDK for the NexoFlow Content API. On npm, MIT licensed.

About nexoflow-sdk

NexoFlow is an AI SEO team for your business: you talk to it in Chat, and it fixes your site, writes pages and posts, and looks after your Google Business Profile, asking before anything big. On a site built from code, the posts it publishes reach your pages through the Content API.

nexoflow-sdk is the typed way to read them from any JavaScript or TypeScript backend: zero dependencies, full TypeScript support, built-in retries, and support for every server runtime with a native fetch.

You don't need it if your site's code is on GitHub and NexoFlow connected it: that pull request reads the API with plain fetch and adds no package.

Why use the SDK?

  • Zero dependencies: nothing extra to audit or break at install time.
  • Full TypeScript: every response is typed, so autocomplete works out of the box.
  • Retries and timeouts: network errors, 5xx and 429 answers retry with exponential backoff automatically.
  • Async iterators: page through large archives with for await.
  • Framework-agnostic: Next.js, Nuxt, SvelteKit, Astro, Remix, Express, Fastify, Cloudflare Workers, Deno, Bun and more.
  • ISR-ready: pass revalidate and the SDK sets Next.js-friendly cache hints.

Install

terminal
npm install nexoflow-sdk
# or
yarn add nexoflow-sdk
pnpm add nexoflow-sdk

Quick start

Your key is your site key, from NexoFlow under Connections, Website, Site key. See your site key for where it goes. The constructor throws if the key is missing or doesn't start with pk_live_.

quick-start.ts
import { NexoFlow } from "nexoflow-sdk"

const nf = new NexoFlow({ apiKey: process.env.NEXOFLOW_API_KEY! })

// List recent posts
const { data } = await nf.posts.list({ limit: 10 })
console.log(data.posts)       // PostListItem[]
console.log(data.pagination)  // { page, limit, total, totalPages, hasMore }

// Get a single post by slug
const { data: post } = await nf.posts.get("my-first-post")
console.log(post.title)
console.log(post.content) // full HTML content

// Iterate over ALL posts (auto-paginates)
for await (const post of nf.posts.iter()) {
  console.log(post.title)
}

Continue with configuration, the posts methods and the framework examples.

What's in the client

One client, two resources:

ResourceMethodsFor
nf.postslist, get, all, slugs, iterYour published posts
nf.siteSettingsgetPermalink structure and feature flags
site-settings.ts
const { data: siteSettings } = await nf.siteSettings.get()

siteSettings.features.enableReadingTime   // show "X min read"?
siteSettings.features.enableSchemaMarkup  // print BlogPosting JSON-LD?
siteSettings.permalinkStructure           // e.g. "/%year%/%month%/%slug%"

The SDK doesn't wrap the other endpoints: structured data, llms.txt, revalidate and verify. Call them with fetch and the same key; the reference has each one.

plain-fetch.ts
const base = "https://nexoflow.net/api/v1/content"
const headers = { Authorization: `Bearer ${process.env.NEXOFLOW_API_KEY}` }

// The JSON-LD for one page, ready for its <head>
const sd = await fetch(`${base}/structured-data?path=/services/drain-cleaning`, { headers })
const { scriptTag } = await sd.json() // scriptTag is absent when jsonld is null

// Your llms.txt, to serve at /llms.txt
const llms = await fetch(`${base}/llms-txt`, { headers })
if (llms.ok) console.log(await llms.text())

You may also see nf.thingsToDo in autocomplete. It reads Things to Do pages from NexoFlow's earlier version, which v2 doesn't make, so it's left out of these docs.

Server-side usage only

Your site key (pk_live_…) is a secret. Treat it like a database password.

Don't

  • Import nexoflow-sdk in browser bundles or React client components
  • Hard-code the key in sources that ship to the browser
  • Use the key in <script> tags, Vite client bundles or browser-only services

Do

  • Store the key in an environment variable (NEXOFLOW_API_KEY)
  • Call the SDK only from server code: Server Components, API routes, server loaders and so on

If the SDK sees a browser (window, document and navigator are all defined), it logs a console warning. It doesn't block the call, but the warning means the key is somewhere it shouldn't be. The API itself doesn't answer browsers calling from other sites.

Response format

list, get and siteSettings.get return the same envelope. all, slugs and iter page through for you and give back the items themselves.

ApiResponse<T>
{
  data: T,               // the API response payload
  rateLimit?: {          // from X-RateLimit-* headers, when a response has them
    limit?: number,
    remaining?: number,
    reset?: number,
  },
  traceId: string,       // the SDK's id for this call, also sent as X-Request-Id
  durationMs: number,    // wall-clock time, retries included
  attempts: number,      // 1 means no retries
}
example.ts
const { data, traceId, attempts } = await nf.posts.list({ limit: 5 })

console.log(data.posts)
console.log(data.pagination)
console.log(traceId, attempts) // e.g. "nf_m3k2…_x7f1qa" 1