What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Use a custom element in an SSR application by keeping ordinary page rendering on the server, moving registration and browser-only interaction into a small client boundary, and testing the element’s property and event contract with the exact React and framework versions you deploy. Next.js and React 19 make this practical, but React’s documented behavior is not automatically the behavior of every SSR framework.
What a web component contributes to an SSR app
A custom element is a browser-defined HTML tag. Its name must follow the custom-element naming rules, including a hyphen, and the browser learns its behavior when code calls CustomElementRegistry.define(). An autonomous element normally extends HTMLElement; it can observe selected attributes through observedAttributes and respond in attributeChangedCallback(). See MDN’s custom-elements guide.
SSR can emit the element’s tag and any useful light-DOM fallback before JavaScript loads. Registration, upgrades, DOM APIs, event listeners, and object-valued properties must wait for the browser. Avoid importing a module that touches window or document as an eager dependency of server-rendered code.
How do I use web components in Next.js?
Keep the page and data on the server
In the App Router, pages and layouts are Server Components by default. They can fetch data and stream the surrounding route HTML. Add a Client Component only where the custom element needs browser APIs, state, lifecycle code, or event handlers. Next.js documents this split in Server and Client Components.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →#1 Best Overall
- Versatile Dual Large-Surface Desk:A 25" × 12.99" workspace. This portable and overbed desk features a flexible layout, designed to hold office essentials like your laptop, popcorn, and coke for a spacious, mobile workstation. It allows you to work from anywhere at home, enhancing your daily living experience
- Height & Angle Adjustable with Easy Mobility : Height adjustable from 17.05" to 29.72" for seated or standing work. The flexible design allows use anywhere at home without compatibility concerns. The desktop tilts and swivels to find your perfect angle, enhancing comfort. It rolls effortlessly on four casters for easy repositioning and convenient access during use
- Upgraded Alloy Steel Frame and Quadrilateral Stable Base: Market's latest structure with alloy frame and reinforced base eliminates wobbling, ensures 10+ years durability. Locking casters and reinforced fasteners provide reliable stability, while this breakthrough construction offers exceptional strength and durability surpassing competing products
- Latest 2025 Model with Ergonomic Design: Data-driven ergonomics provide perfect adult working height. Anti-slip stoppers lock items in place at any tilt. A space-saving hero that transforms tight spaces into efficient workstations anywhere. As the most innovative product of 2025, it is designed to meet everyone's needs
- Quick Tool-Free Assembly: The included instructions allow for quick and easy assembly. Dedicated support is always available if needed. For any questions or issues, please contact us through your order, and we are here to help. This product is protected by intellectual property rights
Place a narrow client boundary around the element
Mark the entry file with 'use client'. That directive defines the server-to-client boundary; files imported below it do not each need the directive. Props crossing the boundary must be serializable, so pass IDs, strings, numbers, booleans, or plain data and construct non-serializable values in the client component. See Next.js’s use client reference.
// app/products/page.tsx (Server Component)
import ProductViewer from './ProductViewer';
export default async function Page() {
const product = await getProduct();
return (
<main>
<h1>{product.name}</h1>
<ProductViewer productId={product.id} />
</main>
);
}
// app/products/ProductViewer.tsx (Client Component)
'use client';
import { useEffect, useRef } from 'react';
export default function ProductViewer({ productId }: { productId: string }) {
const ref = useRef<HTMLElement>(null);
useEffect(() => {
let active = true;
import('./product-viewer.js').then(() => {
if (active && ref.current) {
(ref.current as any).config = { productId };
}
});
return () => { active = false; };
}, [productId]);
return (
<product-viewer ref={ref} product-id={productId}>
<p>Loading product details…</p>
</product-viewer>
);
}
If the definition module can be evaluated more than once, guard registration with customElements.get('product-viewer') before calling define(). This follows the browser registry model and prevents a duplicate-definition exception.
Rank #2
- TILTABLE SPLIT DESKTOP & CUSTOM COMFORT--Tailor your workstation to your exact needs. Features a dual-panel design with a 15"L x 12"W main tiltable table and 8"L x 12"independent mouse pad station. Easily adjust the panel to any ergonomic angle and lock it firmly in place to reduce neck strain, whether you are typing, reading, or drawing in bed.
- INFINITE HEIGHT ADJUSTABILITY --Transition seamlessly from sitting to lounging. Designed with a flexible single-pole single-frame mechanism, this mobile laptop desk can be smoothly raised or lowered from 23" to 33". Find your perfect, personalized posture next to low-profile sofas, standard platform beds, or cozy dorm recliners with a simple, effortless adjustment.
- SAFETY ROLLING DESK WITH EDGE STOPPER--Work with absolute peace of mind. Equipped with a built-in safety edge stopper, this bedside table securely anchors your laptop, tablet, or notebooks, preventing them from sliding off even when the desktop is tilted at maximum angles. Keep your expensive electronics safe while enjoying breakfast or drafting emails.
- STURDY E1 MDF PANEL & WELDED FRAME--Built to last, engineered for safety. Crafted from premium, water-resistant 15mm E1-grade MDF board and backed by a thickened, heavy-duty welded metal frame, this over bed desk proudly supports up to 30 lbs of evenly distributed weight. Experience rock-solid stability with a modern wood-grain look that seamlessly fits any home decor.
- 360° SMOOTH MOBILITY & EASY ASSEMBLY--Roll it anywhere you want, lock it whenever you need. Features 4 heavy-duty 1-inch rolling casters with built-in stop plugs for effort-free movement and rock-solid still-standing
Can I use custom elements with server-side rendering?
Yes, but distinguish server-emitted markup from browser behavior. The server can output a custom tag, primitive attributes, and fallback children. It cannot run the element’s constructor against a real browser DOM or serialize arbitrary JavaScript objects into HTML. Registration and upgrade happen when the client loads the definition.
Preserve meaningful fallback content when the element supports it. Do not branch on browser globals during the initial render in a way that makes the server HTML and the browser’s first render differ.
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #3
- PERFECT FOLDABLE DESIGN: 23.43"(L)x15.75"(W)x9.25"(H).This laptop bed desk is designed to be foldable, allowing you to easily open the table legs for use without any assembly. When not in use, simply fold it in half for compact storage, saving space in your room.
- CONVENIENT CUP HOLDER AND TABLET SLOT: Features a built-in cup holder to securely hold your drink and a stand groove to keep your tablet, or phone upright, making it easy to enjoy your favorite shows or work hands-free.
- MULTI-FUNCTIONAL: This laptop table is designed for versatility.Ideal for various activities like working, studying, reading, eating, or watching movies. Perfect for use on the bed, sofa, floor, balcony, or even outdoors. Can be used as a laptop desk, dining tray, mini writing desk, or picnic table.
- ERGONOMIC AND SPACIOUS DESIGN: The desk dimensions are designed for comfort, providing ample space for laptops, books, or meals. Enjoy an ergonomic setup whether you’re sitting cross-legged on the sofa or lying comfortably in bed.
- EASY TO STORE AND PORTABLE: With its lightweight design, this foldable laptop desk can be easily carried from room to room or taken on outdoor trips. After use, fold it up and store it next to the sofa or under the bed without taking up much space.
How do I pass props to a web component in React?
Use attributes for markup-visible primitive configuration
React describes attributes as string-valued data visible in markup. In React 19 server rendering, primitive props such as strings, numbers, and true are emitted as attributes; false and non-primitive values such as objects, symbols, and functions are omitted. This is the documented React 19 behavior in the React 19 release announcement.
<product-viewer product-id="sku-42" compact={true} />
Use properties for objects and other JavaScript values
React distinguishes properties, which can hold arbitrary JavaScript values, from attributes, which carry strings. During client rendering, when a prop name matches a property on the custom-element instance, React assigns that property; otherwise it assigns an attribute. Therefore an object such as config should be assigned after the element exists, typically through a ref and effect, rather than expected in server HTML.
Rank #4
- Ergonomic Design Bed Desk - Soft wrist rest pad provides your wrist a comfortable place. The retractable blocker protects your computer from falling down. 5 adjustable heights(9.4"-12.6") and 4 adjustable angles (0-36°) provide you a more comfortable posture and avoid back & neck pain.
- Multi-Usage Bed Desk – You can use it easily as a laptop workstation / study solution for college dorm and nursing school essentials for girls and guys /laptop table for bed/children's bed table/mini writing table/standing table for office work/laptop couch table/book/tablet table.
- Stable and Sturdy Laptop Bed Desk: The SAIJI laptop table panel is made of durable wood, which is long lifespan and not easy to break. The table legs are made of high-quality metal which can hold up to 80 pounds of weight. It won’t collapse and break.
- Foldable and Portable Laptop Desk for Bed: SAIJI Laptop desk for bed can be folds flat for space-saving storage. It’s only 1.8 inches thick after folded, so it’s easy to carry and storage. Great for using at home, office or on the road.
- Satisfied customer service: Any question about our SAIJI lap desks bed trays,ss please feel free to contact us via e-mail at first time. SAIJI customer service team will give you a satisfied solution and professional customer service support.
useEffect(() => {
if (ref.current) {
(ref.current as any).config = { theme: 'dark', pageSize: 20 };
}
}, []);
Use the element library’s documented property names and types. Add TypeScript declarations or a small wrapper when your project needs compile-time checking; there is no single universal typing recipe for every custom-element library.
Wire the event the element actually emits
React’s DOM documentation shows custom events through an on-prefixed JSX prop, for example onsubmit for an event named submit. Use the exact event name emitted by your element and verify its payload contract. event.detail is common for CustomEvent, but it is not guaranteed unless the element documents it. See React DOM Components.
Best Value
- 【Adjustable Height Standing Desk】Adjustable height 27"-43.5", you can keep your favorite height. You can sit or stand, 31.5" x 16" tabletop for more storage space.
- 【Ergonomic Home Office Desk】The change between sitting and standing helps you relieve fatigue, avoid health problems of sitting and improve work efficiency, standing desk can improve posture, relieve back and neck pain, provide you with more healthy work position.
- 【Portable Mobile Standing Laptop Desk】4 flexible lockable wheels make the mobile standing desk move where you want, each wheel is equipped with a locking lever so you can hold the desk securely when needed placed in an appropriate location.
- 【Sturdy and Stable Table】Double supports the desktop, even if a 180-pound adult sits on the table, the height of the table will never slip. The table is made of heavy-duty steel, and the middle of the two frames is equipped with a thickened steel frame, which is very stable and is An alternative to standard office and computer desks.
- 【Friendly Customer Service】We provide 7*24 hours after-sales service, 90-day risk-free money-back guarantee, if you have any questions during use, please feel free to contact us, we will provide you with a satisfactory solution.
<product-viewer
onproductselect={(event) => {
const detail = (event as CustomEvent<{ id: string }>).detail;
console.log(detail.id);
}}
/>
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Why does my custom element cause a hydration mismatch?
Hydration attaches behavior to prerendered HTML. Next.js warns when the browser’s initial render does not match that HTML; its guidance is collected in the hydration-error documentation.
Common causes
- A server branch and a browser branch emit different initial markup.
- The element reads
window, time, randomness, layout, or storage while rendering. - Client code renders content only after registration, while the server rendered upgraded-looking content.
- An object property is assumed to have been serialized, so the client’s first output differs.
Hydration-safe remedies
- Make the server and first browser render the same tag, attributes, and fallback children.
- Move browser API access, registration, and property assignment into an effect or another client-only lifecycle point.
- Keep a stable placeholder or light-DOM fallback until the definition is loaded.
- If a component genuinely cannot be prerendered, use an intentional client-only boundary. Next.js documents disabling prerendering for such a component as an option.
suppressHydrationWarning is only a narrow escape hatch for unavoidable text differences. Next.js notes that it applies one level deep and does not repair mismatched markup, so it is not a general custom-element integration strategy.
Which integration strategy fits?
| Strategy | Useful when | Important trade-off |
|---|---|---|
| SSR tag with primitive attributes | The element has meaningful initial HTML and string/number/boolean configuration. | Objects and functions are not represented in server markup. |
| Client-only rendering | The element cannot produce safe initial output or depends entirely on browser APIs. | Less useful HTML before JavaScript and a larger perceived loading gap. |
| Direct React JSX | React 19 and the element’s property/event names are well documented. | Behavior depends on the exact React version and renderer. |
| Small React wrapper | You need typed props, ref-based property assignment, event normalization, or a stable fallback. | More code, but the integration contract is explicit. |
| Global eager registration | The element is required on nearly every route and the module is SSR-safe. | Can increase client work and risks browser-global access during server evaluation. |
| Client-side or lazy registration | Only some routes use the element or its definition is browser-only. | The element remains unupgraded until the definition loads. |
What React 19 changes—and what it does not
React’s December 5, 2024 release announcement states: “React 19 adds full support for custom elements and passes all tests on Custom Elements Everywhere.” React 19’s documented SSR rules and client property assignment improve direct JSX usage, but they do not establish identical behavior for every SSR framework, renderer, or non-React stack.
With another React SSR framework, verify its React version, server renderer, hydration API, and custom-event handling. With a non-React framework, consult that framework’s custom-element integration rules. The general principles still apply: server code must not assume browser globals, and the first hydrated output must be consistent.
Quick Recap
Pre-deployment checklist
- The tag name contains a hyphen and is registered exactly once.
- The definition module is not evaluated on the server if it touches browser globals.
- Server-visible configuration uses attributes only where the element expects attributes.
- Object, array, function, and class-instance values are assigned as properties on the client.
- Event names and
event.detailshapes match the element’s documentation. - The server HTML and first browser render are identical, including fallback children.
- Tests run against the exact React, Next.js or other framework, renderer, and component-library versions used in production.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

