payloadcms / payloadcms/payload
Admin Panel SSR Error: document.createTextNode is not a function
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 44.8k
- Forks
- 4.2k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 53
Description
Bug Report
Describe the Bug
The Payload admin panel returns a 500 error with TypeError: document.createTextNode is not a function during server-side rendering. This prevents the entire admin panel from loading.
Payload Version
- Tested on: 3.68.5, 3.69.0, 3.70.0 (issue persists across all versions)
Adapters and Plugins
- @payloadcms/db-postgres
- @payloadcms/richtext-lexical
- @payloadcms/plugin-multi-tenant
- @payloadcms/plugin-seo
- @payloadcms/plugin-nested-docs
- @payloadcms/plugin-redirects
Error Message
TypeError: document.createTextNode is not a function
at <unknown> (.next/server/app/(payload)/admin/[[...segments]]/page.js:7:107202)
at 18225 (.next/server/app/(payload)/admin/[[...segments]]/page.js:7:107221)
at Object.c [as require] (.next/server/webpack-runtime.js:1:143)
Steps to Reproduce
- Set up Payload CMS with Next.js 15 (standalone output)
- Use the default Lexical rich text editor
- Configure multiple collections with richText fields
- Navigate to
/admin - Admin panel fails with 500 error
Expected Behavior
Admin panel should load normally.
Root Cause Analysis
Lexical editor code that uses DOM APIs (document.createTextNode) is being bundled into the server-side admin page. When Next.js attempts to SSR the admin panel, this code executes on the server where document doesn't have the expected methods.
What I've Tried
- Different Payload versions (3.68.5, 3.69.0, 3.70.0)
- Changed all value imports to type imports:
import type { ... } - Removed unused Lexical imports from plugins/index.ts
- Disabled custom admin components
- Removed
devBundleServerPackages: falsefrom withPayload config - Regenerated importMap multiple times
- Full Docker rebuild with image deletion
None of these resolved the issue.
Environment
- Next.js: 15.4.10
- Node.js: 22.17.1
- Database: PostgreSQL 16
- Deployment: Docker (standalone output)
- OS: Linux (WSL2)
Related
- facebook/lexical#4960 (Lexical SSR limitations)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the failure at /admin with Next.js 15 standalone output and inspect the generated .next/server/app/(payload)/admin/[[...segments]]/page.js bundle. Trace which default Lexical rich text editor code reaches server-side rendering; done means the admin panel loads without the document.createTextNode error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nextjs, node.js, postgres, typescript
- Domain
- build-system, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100