mwg API
    Preparing search index...

    Function encodeShareLink

    • Makes the link for an envelope; throws when the link is longer than maxChars, so a caller that must always produce a link uses fitShareLink or bisectShareLink instead.

      Parameters

      Returns Promise<string>

      import { decodeShareLink, encodeShareLink } from '@datamoc/mwg/core';

      const link = await encodeShareLink({ type: 'state', id: 'pontifex@1.2.0', payload: { seed: 4242 } }, { base: 'https://example.org/play' });
      const read = await decodeShareLink<{ seed: number }>(link);
      console.log(read.ok && read.payload.seed); // 4242