From e48ffa67ee4544177d8dc980536c8906edec501e Mon Sep 17 00:00:00 2001 From: BilalG1 Date: Tue, 16 Sep 2025 18:24:53 -0700 Subject: [PATCH] return to options (#898) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## High-level PR Summary This PR adds an optional `returnTo` parameter to the `signInWithOAuth` function in the Stack Auth SDK. This allows developers to specify a custom redirect URL after OAuth authentication instead of always using the default OAuth callback URL. The change updates both the interface definition and the implementation to support this new optional parameter. ⏱️ Estimated Review Time: 0h 15m
💡 Review Order Suggestion | Order | File Path | |-------|-----------| | 1 | `packages/template/src/lib/stack-app/apps/interfaces/client-app.ts` | | 2 | `packages/template/src/lib/stack-app/apps/implementations/client-app-impl.ts` |
---- > [!IMPORTANT] > Add optional `returnTo` parameter to `signInWithOAuth` for custom redirect URLs in `client-app-impl.ts` and update interface in `client-app.ts`. > > - **Behavior**: > - `signInWithOAuth` in `client-app-impl.ts` now accepts an optional `options` parameter with `returnTo` for custom redirect URLs. > - Default redirect URL is `this.urls.oauthCallback` if `returnTo` is not provided. > - **Interfaces**: > - Updated `signInWithOAuth` signature in `client-app.ts` to include optional `options` parameter with `returnTo`. > > This description was created by [Ellipsis](https://www.ellipsis.dev?ref=stack-auth%2Fstack-auth&utm_source=github&utm_medium=referral) for eb748cbe7775eaba8d261d014951c4140d4bfe5c. You can [customize](https://app.ellipsis.dev/stack-auth/settings/summaries) this summary. It will automatically update as commits are pushed. ## Review by RecurseML _🔍 Review performed on [2d2a6d7..eb748cb](https://github.com/stack-auth/stack-auth/compare/2d2a6d7cd50a3fbc85520706b6c9c107e9b7906a...eb748cbe7775eaba8d261d014951c4140d4bfe5c)_ ✨ No bugs found, your code is sparkling clean
✅ Files analyzed, no issues (2) • `packages/template/src/lib/stack-app/apps/implementations/client-app-impl.ts` • `packages/template/src/lib/stack-app/apps/interfaces/client-app.ts`
[![Need help? Join our Discord](https://img.shields.io/badge/Need%20help%3F%20Join%20our%20Discord-5865F2?style=plastic&logo=discord&logoColor=white)](https://discord.gg/n3SsVDAW6U) ## Summary by CodeRabbit * **New Features** * signInWithOAuth now accepts an optional options parameter with returnTo, allowing apps to override the post-login redirect URL. * Defaults remain unchanged; if returnTo isn’t provided, the existing OAuth callback is used. * Backwards compatible: existing calls without options continue to work. Co-authored-by: Konsti Wohlwend --- .../src/lib/stack-app/apps/implementations/client-app-impl.ts | 4 ++-- .../template/src/lib/stack-app/apps/interfaces/client-app.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/template/src/lib/stack-app/apps/implementations/client-app-impl.ts b/packages/template/src/lib/stack-app/apps/implementations/client-app-impl.ts index 1bff52a88..d5432dcb1 100644 --- a/packages/template/src/lib/stack-app/apps/implementations/client-app-impl.ts +++ b/packages/template/src/lib/stack-app/apps/implementations/client-app-impl.ts @@ -1597,7 +1597,7 @@ export class _StackClientAppImplIncomplete, - signInWithOAuth(provider: string): Promise, + signInWithOAuth(provider: string, options?: { returnTo?: string }): Promise, signInWithCredential(options: { email: string, password: string, noRedirect?: boolean }): Promise>, signUpWithCredential(options: { email: string, password: string, noRedirect?: boolean, verificationCallbackUrl?: string }): Promise>, signInWithPasskey(): Promise>,