Skip to content

decodeBase64Url

function decodeBase64Url(token): string;

Defined in: cursor-codec.ts:98

Decode a base64url (or plain base64) string back to UTF-8. Missing = padding is fine. The default decoder of createCursorCodec; throws on input that isn’t base64.

Parameter Type
token string

string

import { decodeBase64Url } from "@xtandard/lib/pagination";
decodeBase64Url("eyJpZCI6N30"); // '{"id":7}'
decodeBase64Url("eyJpZCI6N30="); // '{"id":7}' (padded base64 works too)
decodeBase64Url("Y2Fmw6kg4piV"); // "café ☕"