Skip to content

docs: add JavaScript SDK quickstart and publish snippets - #534

Closed
techwritermat wants to merge 1 commit into
masterfrom
docs-snippets
Closed

techwritermat wants to merge 1 commit into
masterfrom
docs-snippets

Conversation

@techwritermat

Copy link
Copy Markdown
Contributor

Adds the docs snippets behind the new JavaScript SDK docs IA (proof of concept on the documentation repo, branch sdk-ia-poc). The docs pages currently hard code these snippets and will switch back to EmbeddedCode URLs on master once this merges.

New files in docs-snippets/:

  • quickstart-web.ts and quickstart-web.html: snippet ids quickstartWebInit, quickstartWebListeners, quickstartWebSubscribe, quickstartWebPublish, plus the complete page.
  • quickstart-node.ts and quickstart-node.mjs: snippet ids quickstartNodeListeners, quickstartNodePublish, plus the complete module.
  • quickstart-react.tsx and quickstart-react-app.tsx: snippet ids quickstartReactImports, quickstartReactInit, quickstartReactSubscribe, quickstartReactPublish, plus the complete App.tsx. The subscribe snippet unsubscribes in the effect cleanup so React StrictMode does not subscribe twice.
  • quickstart-commands.sh: shell commands for the quickstarts (not meant to be run as a script).

Extended files:

  • basic-usage/configuration.ts: setUserIdBasicUsage, getUserIdBasicUsage, getAuthKeyBasicUsage, destroyBasicUsage.
  • publish-subscribe.ts: publishMinimal, publishHandleErrors, publishFalsyMessage.

Verification:

  • npm run test:snippets (tsc -p docs-snippets/tsconfig.json --noEmit) passes. It only includes .ts files, so it does not cover the two .tsx files.
  • Ran every new snippet against the demo keyset: the config and publish snippets, the Node quickstart (connects, publishes, receives its own message), and the Web quickstart page in jsdom (connects, publishes, message appears in the list). publishHandleErrors also prints Missing 'message' on a validation failure.
  • Type checked both .tsx files with strict against pubnub 13.1.3 and React 19.3.1, and ran the React app in jsdom under StrictMode: the message appears once with the cleanup and twice without it.

Docs only, no changes to src/ or lib/.

🤖 Generated with Claude Code

Adds the snippets behind the new JavaScript SDK docs IA.

New files in docs-snippets/:
- quickstart-web.ts, quickstart-web.html
- quickstart-node.ts, quickstart-node.mjs
- quickstart-react.tsx, quickstart-react-app.tsx
- quickstart-commands.sh

Extended files:
- basic-usage/configuration.ts: setUserId, getUserId, getAuthKey, destroy
- publish-subscribe.ts: publishMinimal, publishHandleErrors, publishFalsyMessage

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@pubnub-snyk-universal-prd

pubnub-snyk-universal-prd Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@techwritermat
techwritermat deleted the docs-snippets branch November 5, 2026 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant