[]previous and next page

fnId

Stable id of a server function: the first 128 bits of sha256(NFC(relative path) + "#" + export name) in base64url (22 characters).

Stable id of a server function: the first 128 bits of sha256(NFC(relative path) + "#" + export name) in base64url (22 characters).

The path is relative to the project root with / separators, so the id is the same on every machine, in dev and in build, and a rename of the file or the export changes it. It never contains a character that needs escaping in a URL.

Import#

ts
import { fnId } from "@shadow-js/dusk/vite";

Signature#

ts
function fnId(relativePath: string, exportName: string): string

Parameters#

Name Description
relativePath File path relative to the project root. \\ separators are accepted.
exportName Name of the export (default for the default export).

Returns#

A 22-character base64url string.

Examples#

ts
fnId("src/server/posts.ts", "getPost"); // "q3Zr0b1g2yTt0m5Qk9w3xA"