From 2351f52fe3ee5a0ad111bc0d54fc806fb9af80e3 Mon Sep 17 00:00:00 2001 From: Samuel Burkhard <15785987+samydoesit@users.noreply.github.com> Date: Thu, 20 Nov 2025 19:46:35 +0100 Subject: [PATCH 1/2] feat: add options to disable session plugin --- playground/nuxt.config.ts | 2 ++ src/module.ts | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/playground/nuxt.config.ts b/playground/nuxt.config.ts index d4dd9bd7..fd81de03 100644 --- a/playground/nuxt.config.ts +++ b/playground/nuxt.config.ts @@ -29,6 +29,8 @@ export default defineNuxtConfig({ auth: { webAuthn: true, atproto: true, + // disableUserSessionServerPlugin: false, + // disableUserSessionClientPlugin: false, // loadStrategy: 'client-only' }, icon: { diff --git a/src/module.ts b/src/module.ts index 479915af..9c3c04da 100644 --- a/src/module.ts +++ b/src/module.ts @@ -25,6 +25,16 @@ export interface ModuleOptions { * @default false */ webAuthn?: boolean + /** + * Disable User Session Client + * @default false + */ + disableUserSessionClientPlugin?: boolean + /** + * Disable User Session Server + * @default false + */ + disableUserSessionServerPlugin?: boolean /** * Enable atproto OAuth (Bluesky, etc.) * @default false @@ -96,8 +106,12 @@ export default defineNuxtModule({ // App addComponentsDir({ path: resolver.resolve('./runtime/app/components') }) addImports(composables) - addPlugin(resolver.resolve('./runtime/app/plugins/session.server')) - addPlugin(resolver.resolve('./runtime/app/plugins/session.client')) + if (!options.disableUserSessionServerPlugin) { + addPlugin(resolver.resolve('./runtime/app/plugins/session.server')) + } + if (!options.disableUserSessionClientPlugin) { + addPlugin(resolver.resolve('./runtime/app/plugins/session.client')) + } // Server addServerPlugin(resolver.resolve('./runtime/server/plugins/oauth')) addServerImportsDir(resolver.resolve('./runtime/server/lib/oauth')) From 71b3343b2a297b560dd27c8424f17519f208a120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Tue, 9 Dec 2025 15:58:33 +0100 Subject: [PATCH 2/2] fix: use loadStrategy instead --- README.md | 14 ++++++++++++++ playground/nuxt.config.ts | 5 ++--- src/module.ts | 18 +++--------------- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 80d9303c..aa0e517e 100644 --- a/README.md +++ b/README.md @@ -609,6 +609,20 @@ export default defineNuxtConfig({ When using the `client-only` load strategy, the user session can still be manually fetched on the server side by calling `fetch` from the `useUserSession` composable. +### Disable session loading + +You may also choose to disable session loading entirely, with the `loadStrategy` option in your `nuxt.config.ts`: + +```ts +export default defineNuxtConfig({ + auth: { + loadStrategy: 'none' + } +}) +``` + +When using the `none` load strategy, the user session can still be manually fetched by calling `useUserSession().fetch()`. + ### `` component You can use the `` component to safely display auth-related data in your components without worrying about the rendering mode. diff --git a/playground/nuxt.config.ts b/playground/nuxt.config.ts index fd81de03..b664883b 100644 --- a/playground/nuxt.config.ts +++ b/playground/nuxt.config.ts @@ -29,9 +29,8 @@ export default defineNuxtConfig({ auth: { webAuthn: true, atproto: true, - // disableUserSessionServerPlugin: false, - // disableUserSessionClientPlugin: false, - // loadStrategy: 'client-only' + // loadStrategy: 'none', + // loadStrategy: 'client-only', }, icon: { customCollections: [{ diff --git a/src/module.ts b/src/module.ts index 9c3c04da..8c98152a 100644 --- a/src/module.ts +++ b/src/module.ts @@ -25,16 +25,6 @@ export interface ModuleOptions { * @default false */ webAuthn?: boolean - /** - * Disable User Session Client - * @default false - */ - disableUserSessionClientPlugin?: boolean - /** - * Disable User Session Server - * @default false - */ - disableUserSessionServerPlugin?: boolean /** * Enable atproto OAuth (Bluesky, etc.) * @default false @@ -53,7 +43,7 @@ export interface ModuleOptions { * Session load strategy * @default 'server-first' */ - loadStrategy?: 'server-first' | 'client-only' + loadStrategy?: 'server-first' | 'client-only' | 'none' } declare module 'nuxt/schema' { @@ -69,7 +59,7 @@ declare module 'nuxt/schema' { interface PublicRuntimeConfig { auth: { - loadStrategy: 'server-first' | 'client-only' + loadStrategy: 'server-first' | 'client-only' | 'none' } } } @@ -106,10 +96,8 @@ export default defineNuxtModule({ // App addComponentsDir({ path: resolver.resolve('./runtime/app/components') }) addImports(composables) - if (!options.disableUserSessionServerPlugin) { + if (options.loadStrategy !== 'none') { addPlugin(resolver.resolve('./runtime/app/plugins/session.server')) - } - if (!options.disableUserSessionClientPlugin) { addPlugin(resolver.resolve('./runtime/app/plugins/session.client')) } // Server