Skip to content

docs: document Buffer polyfill required by the Tron adapter - #107

Open
ScreamingHawk wants to merge 1 commit into
mainfrom
docs/buffer-polyfill
Open

docs: document Buffer polyfill required by the Tron adapter#107
ScreamingHawk wants to merge 1 commit into
mainfrom
docs/buffer-polyfill

Conversation

@ScreamingHawk

Copy link
Copy Markdown
Contributor

TronWeb, pulled in by @0xtrails/tvm, reads the Node Buffer global while its modules evaluate. In a browser that throws ReferenceError: Buffer is not defined on import and takes down the surrounding React tree — a blank page, not a caught error.

This bit app.trails.build in production (0xsequence/trails-app#48). The SDK demo app hit the same thing earlier and carries the same polyfill, so it is worth documenting rather than rediscovering a third time.

Changes to sdk/adapters/overview.mdx

  • Adds tronAdapter / @0xtrails/tvm to the available adapters table — it was missing entirely
  • New "Buffer polyfill for Tron" section: the symptom, the polyfill, and why import order matters
  • Adds Tron to the "Choosing an adapter" list

On the SVM question

I checked rather than assumed. Built app.trails.build with svmAdapter alone and no polyfill, loaded it in headless Chromium: typeof globalThis.Buffer === "undefined", zero errors, page renders normally. Solana genuinely does not need it, so the docs say so explicitly instead of vaguely grouping the two edge rails together.

Caveat called out in the docs

The polyfill only works if it evaluates before TronWeb. Bundlers that hoist or split entries can reorder that, so the section points at build-time injection (Vite define, webpack.ProvidePlugin) as the more robust fallback.

mintlify broken-links passes.

TronWeb reads the Node `Buffer` global at module-eval time, so importing
`tronAdapter` in a browser throws without a polyfill.

Also lists `tronAdapter` in the available adapters table and notes that
`svmAdapter` does not need the polyfill.
@mintlify

mintlify Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
trails 🟢 Ready View Preview Aug 18, 2026, 10:53 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

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