[]previous and next page

nextKey

Draws the key of the next template root in the current scope: what template() and ssrHydrationKey() call, in the same order on the server and the client.

Draws the key of the next template root in the current scope: what template() and ssrHydrationKey() call, in the same order on the server and the client. Each call advances the scope.

Import#

ts
import { nextKey } from "@shadow-js/web/extend";

Signature#

ts
function nextKey(): string | undefined

Returns#

The key ("0-0", "0-1", ...); undefined outside a scope.

Examples#

ts
import { claimElement, nextKey } from "@shadow-js/web/extend";

function createBadge(): Element {
  return claimElement(nextKey()) ?? document.createElement("span");
}