TypeScript SDK
TypeScript SDK
Add ads to web and Node apps with @yellesoftware/meridian-ads. Signing, headers, and serve calls are built in.
Install
Use Node.js 18 or newer. @yellesoftware/meridian-ads is on the public npm registry. No token or .npmrc is required.
npm
npm install @yellesoftware/meridian-ads pnpm: pnpm add @yellesoftware/meridian-ads. Yarn: yarn add @yellesoftware/meridian-ads.
Node projects that stay in JavaScript use this package from the server. See the JavaScript guide .
Serve, render, click
Create a client with your app key and secret from the console. Call serve with a placement name and user ID, then recordImpression when the ad is visible.
TypeScript
import { MeridianAds } from '@yellesoftware/meridian-ads'
const client = new MeridianAds({
appKey: process.env.MERIDIAN_ADS_APP_KEY,
secret: process.env.MERIDIAN_ADS_SECRET,
})
const decision = await client.serve('home', 'user-42', { country: 'US', plan: 'pro' })
if (!decision) {
// HTTP 204: no paid or house fill
} else {
await client.recordImpression(decision)
}Next
See Users and context for what to pass in each request, and Impressions and clicks for the render order.