Skip to content

@sharedid-edge/modules ​

The list of modules built into every SharedID Edge adapter: ip, geo, reflect, bot and ua. The Cloudflare Worker, the Node.js server, the AWS Lambda function, the Vercel adapter, the Azure Functions app and the Google Cloud function all import it, so a module added here is available on every platform at once.

Vendor modules, and ec (Trusted Server Edge Cookies, whose ID is derived from the IP address), aren't in it: a deployer adds them at build time. See Vendor modules.

Being built in doesn't turn a module on. Each one does nothing until it's listed in SID_MODULES; see the Modules section.

Using it in code ​

ts
import { createHandler, resolveConfig } from '@sharedid-edge/core';
import { builtInModules } from '@sharedid-edge/modules';

const handler = createHandler({ config: resolveConfig(env), modules: builtInModules });

builtInModules is a frozen readonly EdgeModule[]. To add a module of your own, or a vendor module, pass a longer list:

ts
import { builtInModules } from '@sharedid-edge/modules';
import { myModule } from './my-module.js';

const modules = [...builtInModules, myModule];

Vendor modules (in packages/vendor-modules/) are never in this list: a deployer opts in to each one when building.

With Bowser ​

@sharedid-edge/modules/bowser exports the same builtInModules, with uaModuleWithBowser in place of uaModule, so SID_MODULE_CONFIG={"ua":{"parser":"bowser"}} can parse User-Agents fully. It's what the adapters' Bowser builds alias in (deploy:bowser, bundle:bowser) and what the Node.js server uses. It adds about 8 to 8.7 KB gzipped to a bundle; see Full parsing with Bowser.