Full Toolkit for Next-Level Domain Analysis
Prevent hydration mismatch from keyboard shortcut indicators ✅
Felix Wotschofsky09213297e248
diff --git a/app/_components/search-form.tsx b/app/_components/search-form.tsxindex 0e8ccce..baca0e1 100644--- a/app/_components/search-form.tsx+++ b/app/_components/search-form.tsx@@ -21,6 +21,7 @@ import useSWR from 'swr';import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';+import { ClientOnly } from '@/components/client-only';import { EXAMPLE_DOMAINS } from '@/lib/data';import { cn, isAppleDevice, isValidDomain } from '@/lib/utils';@@ -255,15 +256,17 @@ export const SearchForm: FC<SearchFormProps> = (props) => {autoFocus={props.autofocus}/>- <kbd className="pointer-events-none absolute right-3 top-1/2 hidden h-5 -translate-y-1/2 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium opacity-100 sm:flex">- {isAppleDevice() ? (- <>- <span className="text-xs">⌘</span>K- </>- ) : (- 'ctrl+k'- )}- </kbd>+ <ClientOnly>+ <kbd className="pointer-events-none absolute right-3 top-1/2 hidden h-5 -translate-y-1/2 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium opacity-100 sm:flex">+ {isAppleDevice() ? (+ <>+ <span className="text-xs">⌘</span>K+ </>+ ) : (+ 'ctrl+k'+ )}+ </kbd>+ </ClientOnly>{suggestionsVisible && suggestions && suggestions.length > 0 && (<ul className="absolute left-0 top-full w-full rounded-xl border bg-card p-1 text-card-foreground shadow">diff --git a/app/lookup/[domain]/_components/results-tabs.tsx b/app/lookup/[domain]/_components/results-tabs.tsxindex 76bd457..684fd5b 100644--- a/app/lookup/[domain]/_components/results-tabs.tsx+++ b/app/lookup/[domain]/_components/results-tabs.tsx@@ -6,6 +6,7 @@ import { useRouter, useSelectedLayoutSegment } from 'next/navigation';import type { FC } from 'react';import { useHotkeys } from 'react-hotkeys-hook';+import { ClientOnly } from '@/components/client-only';import { isAppleDevice } from '@/lib/utils';type SingleTabProps = {@@ -31,19 +32,21 @@ const SingleTab: FC<SingleTabProps> = ({}>{label}- <span- className="pointer-events-none absolute bottom-0 left-1/2 hidden w-full -translate-x-1/2 translate-y-4 text-xs text-muted-foreground opacity-0 transition-all group-hover:translate-y-6 group-hover:opacity-100 sm:block"- aria-hidden- >- {isAppleDevice() ? (- <>- <OptionIcon className="inline-block h-3 w-3" strokeWidth={3} />- {` + ${shortcutNumber}`}- </>- ) : (- `alt+${shortcutNumber}`- )}- </span>+ <ClientOnly>+ <span+ className="pointer-events-none absolute bottom-0 left-1/2 hidden w-full -translate-x-1/2 translate-y-4 text-xs text-muted-foreground opacity-0 transition-all group-hover:translate-y-6 group-hover:opacity-100 sm:block"+ aria-hidden+ >+ {isAppleDevice() ? (+ <>+ <OptionIcon className="inline-block h-3 w-3" strokeWidth={3} />+ {` + ${shortcutNumber}`}+ </>+ ) : (+ `alt+${shortcutNumber}`+ )}+ </span>+ </ClientOnly></Link></li>);diff --git a/components/client-only.tsx b/components/client-only.tsxnew file mode 100644index 0000000..4793d91--- /dev/null+++ b/components/client-only.tsx@@ -0,0 +1,16 @@+// Based on https://github.com/dubinc/dub/blob/03afa158f3c8d5026c9c758883ec2939aa441ba6/packages/ui/src/client-only.tsx+import { type FC, type ReactNode, useEffect, useState } from 'react';++type ClientOnlyProps = {+ children: ReactNode;+};++export const ClientOnly: FC<ClientOnlyProps> = ({ children }) => {+ const [clientReady, setClientReady] = useState(false);++ useEffect(() => {+ setClientReady(true);+ }, []);++ return clientReady ? children : null;+};