crelte / std/rand / createRng
Function: createRng()
ts
function createRng(key, crelte): () => number;Create a deterministic random number generator.
Intended use: create this once during component initialization when a sequence of random values must be consistent between server-side rendering and client hydration.
The generator is seeded during SSR using the provided key. During hydration, the same seed is reused so that the client produces the same sequence of random numbers as the server for the initial render.
After hydration, the generator continues independently on the client.
Parameters
key
string
crelte
Crelte = ...
Returns
A function that returns a pseudo-random number in the range [0, 1).
Example
ts
const rng = createRng('lucky-number');
const val1 = rng(); // same on server and client
const val2 = rng(); // same on server and clientts
(): number;Returns
number