Skip to content

bug: Next.js 13 custom server + SSR + Hydration #4389

@mbulfair

Description

@mbulfair

Prerequisites

Stencil Version

3.2.2

Current Behavior

This is a extension from the Stencil Discord thread, where a issue was asked to log an issue that can replicate the issues my team is seeing while trying to use NextJS 13.4+ with Stencil 3.3.2 and hydrate renderToString with a custom server to provide the server with a hydrated document.

Example screenshot

image

Expected Behavior

I expect the server and client to be in sync from an initial render, with the expectation that fetching and interactive elements won't be available

System Info

System: node 16.19.0
    Platform: darwin (22.2.0)
   CPU Model: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz (12 cpus)
       Build: 1682947516
     Stencil: 3.2.2 🏒
  TypeScript: 4.9.5
      Rollup: 2.42.3
      Parse5: 7.1.2
      Sizzle: 2.42.3
      Terser: 5.17.1

Steps to Reproduce

The repo linked is a NX/Lerna repo

Note: Created quickly so it's not optimized for ease of use

  • npm install
  • npx lerna bootstrap
  • npx nx run @matt/stencil-components:build
  • npx nx run @matt/react-library:build
  • Non Custom Server - npx nx run next-13-demo:dev - Warning with extra attribute
  • Custom Server - npx nx run next-13-demo:dev:custom - Hydration Mismatch Error - Breaking

Code Reproduction URL

https://github.com/mbulfair/nextjs13-ssr-hydration

Additional Information

Discord Thread - https://discord.com/channels/520266681499779082/1107698585002319883

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions