Carlos P

The Day Amplify Broke in Dev (and How We Actually Fixed It) - “Auth UserPool Not Configured”

by

(And why so many developers hit this exact wall when upgrading to Amplify v6)

1️⃣ The Problem That Made No Sense

One morning, our authentication suddenly broke in all V0 Preview builds.

Every login attempt failed with:

Amplify has not been configured.
❌ Error signing in: Auth UserPool not configured.

But production was still working perfectly.

Even older commits that used to work were now broken in development.

So we thought “Something in our environment changed… but what?”

We were right — and wrong.

2️⃣ The Hidden Trigger: Silent Upgrade to Amplify Gen 2

The root cause was invisible:

V0 Preview builds install fresh dependencies every time.

And in our package.json, we had:

"aws-amplify": "latest"

Which means “Install the newest major version, even if it breaks everything.”

V0 upgraded us automatically from:

  • Amplify Gen1 (v5.x)

  • Amplify Gen2 / Unified Architecture (v6.x)

Production was still running v5.
Preview was silently upgraded to v6.

Boom. Total breakage.

3️⃣ Our Debugging Timeline (What We Tried First — and Why Those Attempts Failed)

This is important, because most developers upgrading to v6 hit the same traps.

Here is what we tried — and why each attempt didn’t solve the issue alone:

Attempt #1 — Replace the old monolithic package with modular packages

We tried:

npm add @aws-amplify/core @aws-amplify/auth @aws-amplify/utils
npm remove aws-amplify

We updated:

  • aws-config.ts

  • auth-context.tsx

  • Dashboard pages

But Amplify still reported “UserPool not configured.”

Why?
Because AWS now recommends using the unified v6 package, not the modular subpackages.
Mixing both = inconsistent global config.

Attempt #2 — Fix the import paths

We corrected imports like:

import { Hub } from '@aws-amplify/core'

and replaced them with unified v6 imports.

Still broken.

Attempt #3 — Add the SSR flag (critical! but not enough alone)

In Next.js App Router, Amplify v6 requires:

Amplify.configure(outputs, { ssr: true });

We added it.

Now SSR worked correctly — but auth still failed with UserPool not configured.

Attempt #4 — Fix timing issues

We discovered:

  • Amplify.configure() was running inside a React useEffect

  • That caused race conditions

  • The Auth module was being called before Amplify finished configuring

We moved configuration to a synchronous module-level block.

Better… but still hitting the error.

Attempt #5 — Verified all envs & context providers

We checked everything:

  • AmplifyProvider

  • AuthContext

  • Login page

  • Dashboard pages

All correct.
Still broken.

4️⃣ The Real Breakthrough: Using the Unified Amplify v6 Package

After reading AWS’s own migration examples carefully we realized:

👉 The correct imports for Amplify Gen2 are NOT the modular packages.

👉 They are the unified v6 package (aws-amplify).

AWS changed the architecture:

❌ Wrong (old modular approach)

import { Auth } from '@aws-amplify/auth'
import { Amplify } from '@aws-amplify/core'

✅ Correct (Amplify Gen2 unified API)

import { Amplify } from 'aws-amplify'
import { signIn, fetchAuthSession } from 'aws-amplify/auth'

Everything must come from:

  • aws-amplify

  • aws-amplify/auth

  • aws-amplify/utils

NOT from:

  • @aws-amplify/auth

  • @aws-amplify/core

  • @aws-amplify/utils

Because only the unified v6 package shares the global configuration correctly.

5️⃣ Final Working Configuration (What Actually Fixed Everything)

Step 1 — Remove all modular packages

npm remove @aws-amplify/auth @aws-amplify/core @aws-amplify/utils

Step 2 — Install unified v6 package

npm install aws-amplify@6

Step 3 — Configure Amplify correctly

aws-config.ts:

import { Amplify } from 'aws-amplify'
import outputs from '../amplify_outputs.json'

Amplify.configure(outputs, { ssr: true })

console.log("✅ Amplify configured successfully")

Step 4 — Use correct v6 modular imports

Login:

import { signIn } from "aws-amplify/auth"

await signIn({
  username,
  password,
})

Session checks:

import { fetchAuthSession } from "aws-amplify/auth"

Hub:

import { Hub } from "aws-amplify/utils"

Step 5 — Ensure configuration runs ONLY once, synchronously, at module level

No useEffect.
No repeated providers.
No duplicated configuration.

6️⃣ Result: Everything Works. And It’s Much Faster.

  • No more "UserPool not configured".

  • SSR works correctly.

  • Tokens stored in cookies.

  • Auth context loads reliably.

  • Smaller, modular bundle compared to Gen1.

  • Works consistently across Dev, Preview, and Prod.

7️⃣ Final Takeaway

If you’re upgrading to Amplify Gen2 and hitting:

Auth UserPool not configured
Amplify has not been configured

The real fix is:

Use the unified aws-amplify v6 package for ALL imports and ensure a single synchronous root-level configuration with { ssr: true }.

Every other fix is incomplete unless you do that.

8️⃣ Hope This Saves Someone Hours of Debugging

If you found this useful, drop a comment or share it with anyone fighting Amplify 🔥

We’re building AI-powered real-estate video tools at:
👉 https://www.videodefotos.com

16 views

Add a comment

Replies

Be the first to comment