Skip to content

feat(adapter-nextjs): support dynamic redirect after sign-in using redirectTo query param#14779

Open
TiwariLokesh wants to merge 1 commit intoaws-amplify:mainfrom
TiwariLokesh:feat/redirect-after-signin
Open

feat(adapter-nextjs): support dynamic redirect after sign-in using redirectTo query param#14779
TiwariLokesh wants to merge 1 commit intoaws-amplify:mainfrom
TiwariLokesh:feat/redirect-after-signin

Conversation

@TiwariLokesh
Copy link
Copy Markdown

Description of changes

This PR adds support for dynamic redirects after sign-in in the Next.js adapter by introducing a redirectTo query parameter.

Currently, users are always redirected to a static redirectOnSignInComplete path after authentication. This change allows users to be redirected back to their originally requested page.

Issue #, if available

Fixes #14677

Description of how you validated changes

  • Verified redirect logic by extracting and testing query parameter handling locally

  • Confirmed that:

    • Valid relative paths (e.g. /dashboard) are correctly used for redirection
    • Invalid or external URLs (e.g. https://example.com) are ignored
    • Fallback to redirectOnSignInComplete works when redirectTo is absent or invalid
  • Successfully built the project using yarn build with no errors

Checklist

  • PR description included
  • yarn test passes
  • Unit Tests are changed or added
  • Relevant documentation is changed or added

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 12, 2026

⚠️ No Changeset found

Latest commit: d346c9b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@bobbor
Copy link
Copy Markdown
Member

bobbor commented Apr 30, 2026

hey @TiwariLokesh

This PR looks good so far. While I can see the use-case for scenario-specific redirectTo-URL's, I cannot understand how you would specify them. 😕

Can you quickly guide me through your flow? Ideally highlighting, when you would set the redirectTo at the beginning of signIn, and how you've configured (keeping out secrets) your cognito - should you use it - or another auth. Then maybe we can find a solution, which works now already or at least I'd understand and we can go ahead with your proposed changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

adapter-nextjs: redirect to the originally requested url after sign-in

2 participants