@jmediagroup/platform-sdk
v0.3.3
Published
Adds the J Media Group applet to a client site: a server route that signs requests to the JMG Hub, and the launcher component.
Readme
@jmediagroup/platform-sdk
Adds the J Media Group website-help applet to a client's Next.js (App Router) site. Client staff use it to start a project, report a problem or request a website update, and to see the status of each request.
This package is for sites J Media Group looks after. It does nothing without a key issued by J Media Group, and it holds no secret of its own.
Set up
npm install --save-exact @jmediagroup/platform-sdk
npx @jmediagroup/platform-sdk init # add --passcode for a site with no staff logininit writes the server route, the config and the launcher, and lists what is left: render <WebsiteHelp />, say who is staff, and set one environment variable, JMG_PLATFORM_TOKEN.
What's in it
@jmediagroup/platform-sdk/server:createJmgHandler(), the site's/api/jmgroute. It signs each request with the site's key, which stays on the server. Needs the Node.js runtime.@jmediagroup/platform-sdk/react:<JmgApplet />, the launcher, and<JmgDashboard />, the same applet as a full page for a site's staff area. Both show nothing unless the applet is switched on for the site and the visitor is staff.@jmediagroup/platform-sdk/next:jmgFontHeaders()fornext.config, so the applet can use the site's own fonts.@jmediagroup/platform-sdk:defineConfig()and the shared types.
The look
The applet reads the page it is on: background, text, fonts, and the color and corners of the page's main button. To pin a part to one of the site's design tokens, name the token in jmg.config.ts:
export default defineConfig({ theme: { action: "--color-action", fontHeading: "--font-display" } });Roles: surface, surfaceRaised, text, textMuted, border, action, actionText, actionHover, focusRing, error, radiusControl, radiusPanel, shadow, fontBody, fontHeading, fontLabel, labelTransform, labelTracking.
Rules for a site
- The token goes in an environment variable. Never in code, in git, or in a
NEXT_PUBLIC_variable. - The browser never calls J Media Group directly. Only the server route does.
Patch and minor releases never need a change to a site's code.
All rights reserved. Published so client sites can install it, not licensed for reuse.
