Adds initialSessionAuthContext support for SessionAuth component. initialSessionAuthContext is an initial state that Session provider uses to create a context.
Added initialSessionAuthContext property to SessionAuthProps
Added isContextFromSSR to LoadedSessionContext that signals if a session context is provided from a server or computed on the client.
isContextFromSSR: true when uses initial context preloaded from server (SSR). This means invalidClaims[] and accessDeniedValidatorError are not yet evaluated and the client should not trust the data (as discussed with @porcellus )
isContextFromSSR: false when uses a client generated context (ex: after client rerender)
Tested locally on a NextJS implementation using supertokens. Tested scenarios include:
Tested <SessionAuth /> rendering with children that consume context (userId) -> Renders on server side, no flash or hydration issues
Tested with requireAuth: false on server component. -> <SessionAuth /> provides an empty session context and renders children
Documentation changes
TODO.
(If relevant, please create a PR in our docs repo, or create a checklist here highlighting the necessary changes)
Checklist for important updates
[ ] Changelog has been updated
[ ] frontendDriverInterfaceSupported.json file has been updated (if needed)
[ ] Changes to the version if needed
In package.json
In package-lock.json
In lib/ts/version.ts
[x] Had run npm run build-pretty
[x] Had installed and ran the pre-commit hook
[ ] Issue this PR against the latest non released version branch.
To know which one it is, run find the latest released tag (git tag) in the format vX.Y.Z, and then find the latest branch (git branch --all) whose X.Y is greater than the latest released tag.
If no such branch exists, then create one from the latest released branch.
[ ] If added a new recipe interface, then make sure that the implementation of it uses NON arrow functions only (like someFunc: function () {..}).
[ ] If I added a new recipe, I also added the recipe entry point into the size-limit section of package.json with the size limit set to the current size rounded up.
[ ] If I added a new recipe, I also added the recipe entry point into the rollup.config.mjs
Remaining TODOs for this PR
[x] Add getInitialSessionAuthContext support to supertokens-node
Summary of change
Adds
initialSessionAuthContext
support forSessionAuth
component.initialSessionAuthContext
is an initial state that Session provider uses to create a context.initialSessionAuthContext
property toSessionAuthProps
isContextFromSSR
toLoadedSessionContext
that signals if a session context is provided from a server or computed on the client.isContextFromSSR: true
when uses initial context preloaded from server (SSR). This meansinvalidClaims[]
andaccessDeniedValidatorError
are not yet evaluated and the client should not trust the data (as discussed with @porcellus )isContextFromSSR: false
when uses a client generated context (ex: after client rerender)Related issues
Test Plan
Tested locally on a NextJS implementation using supertokens. Tested scenarios include:
<SessionAuth />
rendering with children that consume context (userId) -> Renders on server side, no flash or hydration issuesrequireAuth: false
on server component. -><SessionAuth />
provides an empty session context and renders childrenDocumentation changes
TODO.
(If relevant, please create a PR in our docs repo, or create a checklist here highlighting the necessary changes)
Checklist for important updates
frontendDriverInterfaceSupported.json
file has been updated (if needed)package.json
package-lock.json
lib/ts/version.ts
npm run build-pretty
git tag
) in the formatvX.Y.Z
, and then find the latest branch (git branch --all
) whoseX.Y
is greater than the latest released tag.someFunc: function () {..}
).size-limit
section ofpackage.json
with the size limit set to the current size rounded up.rollup.config.mjs
Remaining TODOs for this PR
getInitialSessionAuthContext
support tosupertokens-node