Bug: Lexical Collaboration Plugin is not working properly with Next.js 14 app router
- Dominant language
- TypeScript
- Stars
- 23.9k
- Forks
- 2.2k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 57
Description
My Lexical editor was working perfectly fine with Next.js page router. But after I updated my project to use Next.js App Router, the lexical editor's collaboration plugin was not working properly. Sometimes, the lexical changes are not synced between collaborators. I'm using y-websocket for the yjs Websocket provider. Does this has anything to do with how Next.js app router works?
Lexical version: ^0.14.5
## Steps To Reproduce
1. Running the lexical playground in a Next.js app router project.
My code in page router and app router are exactly the same, but the issue occurs with app router:
App router test page: (which has issue)
```
import LexicalWrapper from '../../modules/lexical/LexicalWrapper';
import EditorWrapper from '../../modules/lexical/EditorWrapper';
type Props = {}
function TestPage({ }: Props) {
return (
)
}
export default TestPage
```
Page router test page: (which works fine)
```
import EditorWrapper from "../modules/lexical/EditorWrapper"
import LexicalWrapper from "../modules/lexical/LexicalWrapper"
type Props = {}
function TestPage({ }: Props) {
return (
)
}
export default TestPage
```
## The current behavior
With the app router test page:
- If I have two browsers accessing an empty note, in which the root is empty, and I start typing in one of the browser (browser A), the other browser (browser B) can sync successfully with the changes. However, as soon as I start typing in the browser B, the changes do not reflect in browser A's lexical editor. I'm thinking maybe either browser A is not sending the lexical changes to yjs for syncing or browser B cannot listen to the changes from yjs.
## The expected behavior
- Two browsers should sync the lexical changes successfully.
Contributor guide
Assessment
This issue has not been assessed yet.