hono-cookie-state
    Preparing search index...

    Interface CreateCookieStateParams<T>

    interface CreateCookieStateParams<T extends Record<string, any>> {
        autoRefreshSession?: boolean;
        cookieKey?: string;
        cookieOptions?: CookieOptions;
        initData?: (c: Context) => Awaitable<T>;
        key: string;
        secret?: string | ((env: Record<string, string | undefined>) => string);
    }

    Type Parameters

    • T extends Record<string, any>
    Index

    Properties

    autoRefreshSession?: boolean

    Whether to refresh the session automatically when its near expiration (16 minutes)

    true
    
    cookieKey?: string

    Name of the cookie

    ${key}
    
    cookieOptions?: CookieOptions
    initData?: (c: Context) => Awaitable<T>

    The initial data of the CookieState instance

    NOTE: This function is run even if there is data from the previous cookie, data is shallow merged together.

    key: string

    Main key, used as Hono variable name and default cookie name

    secret?: string | ((env: Record<string, string | undefined>) => string)

    Secret used to sign the cookie, min length is 32

    While the interface allows optional and have a default value, it will log a WARNING if no secret is explicitly provided (due to some runtime's constraints to access env vars on init)

    ${env.COOKIE_STATE_SECRET}