Next.js SDK Cookie Size is Too High

Problem statement

The cookie generated by Auth0 Next.js SDK is relatively high, and this is causing issues with the API gateway/cloud vendor.

Cause

The Auth0 Next.js SDK stores the session information in an " appSession " cookie by default. This session includes tokens the user receives, which can be a few kilobytes in size.
If there are other cookies in the domain that add up to the size and if using a cloud platform that has a cap on header or cookie sizes, this can potentially cause issues.

Solution

The Next.js SDK lets the session be stored elsewhere rather than in a cookie. The Use a custom session store section in this document explains how this can be done.

This requires some work, but the cookie will only contain an identifier when this is done so that the cookie size will be negligible.