Skip to content
Discussion options

You must be logged in to vote

This happens because the text rendered during SSR has to match the text React produces on the first browser render. new Date().toLocaleDateString() is not stable for that: it depends on the current time, locale, and time zone. The Next.js hydration-error docs list time-dependent APIs like Date() in render as a common cause.

Also, for a registration date you probably do not want new Date() there; use the actual stored registration timestamp and format that.

For a user-local display, keep the page as a Server Component and move only the formatting into a small Client Component:

// app/local-registration-date.tsx
'use client'

import { startTransition, useEffect, useState } from 'react'

export

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@icyJoseph
Comment options

@krotname
Comment options

Answer selected by icyJoseph
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@icyJoseph
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
5 participants