Skip to content

createAmplifyAuthAdapter fails because Amplify.geConfig is empty. #6534

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
4 tasks done
r-3110 opened this issue Apr 30, 2025 · 1 comment
Open
4 tasks done

createAmplifyAuthAdapter fails because Amplify.geConfig is empty. #6534

r-3110 opened this issue Apr 30, 2025 · 1 comment
Labels
pending-community-response Issue is pending response from the issue requestor or other community members question General question StorageBrowser

Comments

@r-3110
Copy link

r-3110 commented Apr 30, 2025

Before creating a new issue, please confirm:

On which framework/platform are you having an issue?

React

Which UI component?

Storage

How is your app built?

vite

What browsers are you seeing the problem on?

Chrome

Which region are you seeing the problem in?

ap-northeast-1

Please describe your bug.

createAmplifyAuthAdapter fails because Amplify.geConfig is empty.

When I checked the source code, I found that Amplify.getConfig on line 27 retrieves an empty object.

Why does it become empty? My amplify_outputs.json is not empty.

I'm trying it with a minimal implementation as per the official documentation, but I get an error.

However, if I execute Amplify.getConfig myself just before executing createAmplifyAuthAdapter, I can get the settings.

I don't understand the cause of this difference. Is it a different instance of the Amplify class? If there is an error, please let me know.

I have confirmed the following.

  • According to pnpm, the dependency of ui-storage seems to be up to react 18, but the result is the same with react 18.

  • amplify ui is imported and executed on the client side.

  • Authentication with Amplify is successful. So, in terms of the authentication flow, AWS.configure seems to be fine.

My environment is as follows:

  • node22
  • pnpm 10
  • vite6
  • react19
  • react router7 (ssr: false)

What's the expected behaviour?

  • Amplify.getConfig should not be empty.
  • createAmplifyAuthAdapter should not have an error.

Help us reproduce the bug!

  1. create vite
npx create-vite
  • select react19 & react router v7

https://vite.dev/guide/#scaffolding-your-first-vite-project

  1. amplify install
pnpm add @aws-amplify/ui-react-storage @aws-amplify/ui-react aws-amplify
  1. add router config and page

  2. start server

pnpm run dev
  1. access storage ui

http://localhost:3000/s3-ui-test

Code Snippet

  • package.json
{
  "name": "vite",
  "private": true,
  "type": "module",
  "scripts": {
    "build": "react-router build",
    "dev": "react-router dev",
    "start": "react-router-serve ./build/server/index.js",
    "typecheck": "react-router typegen && tsc"
  },
  "dependencies": {
    "@aws-amplify/ui-react": "^6.11.1",
    "@aws-amplify/ui-react-storage": "^3.10.2",
    "@react-router/node": "^7.5.3",
    "@react-router/serve": "^7.5.3",
    "aws-amplify": "^6.14.4",
    "isbot": "^5.1.27",
    "react": "^19.1.0",
    "react-dom": "^19.1.0",
    "react-router": "^7.5.3"
  },
  "devDependencies": {
    "@react-router/dev": "^7.5.3",
    "@tailwindcss/vite": "^4.1.4",
    "@types/node": "^22.15.3",
    "@types/react": "^19.1.2",
    "@types/react-dom": "^19.1.2",
    "react-router-devtools": "^1.1.10",
    "tailwindcss": "^4.1.4",
    "typescript": "^5.8.3",
    "vite": "^6.3.3",
    "vite-tsconfig-paths": "^5.1.4"
  }
}
  • routes.ts
import { type RouteConfig, index, route } from "@react-router/dev/routes";

export default [
  index("routes/home.tsx"),
  route("s3-ui-test", "./routes/s3-ui-test.tsx"),
] satisfies RouteConfig;
  • s3-ui-test.tsx
import {
  createAmplifyAuthAdapter,
  createStorageBrowser,
} from "@aws-amplify/ui-react-storage/browser";
import "@aws-amplify/ui-react-storage/styles.css";
import { Amplify } from "aws-amplify";
import outputs from "../../amplify_outputs.json";

Amplify.configure(outputs);
// debug config
console.log("Amplify config", Amplify.getConfig());

const { StorageBrowser } = createStorageBrowser({
  config: createAmplifyAuthAdapter(),
});

export default function S3UITest() {
  return (
    <main>
      <StorageBrowser />
    </main>
  );
}

Console log output

  • createAmplifyAuthAdapter error log
Error: Amplify Storage configuration not found. Did you run Amplify.configure from your project root?
  • Amplify.getConfig() in Storage Key(masked json)
{
  "aws_region": "ap-northeast-1",
  "bucket_name": "amplify-xxxxxxxxxxxxxxxxx",
  "buckets": [
    {
      "name": "<bucket_name>",
      "bucket_name": "amplify-xxxxxxxxxxxxxxxxx",
      "aws_region": "ap-northeast-1"
    }
  ]
}

Additional information and screenshots

  • in createAmplifyAuthAdapter
Image
  • error
    Image
@github-actions github-actions bot added pending-triage Issue is pending triage pending-maintainer-response Issue is pending response from an Amplify UI maintainer labels Apr 30, 2025
@ashika112
Copy link
Contributor

ashika112 commented Apr 30, 2025

Could you try moving your Amplify.configure to your app's entry point rather than withtin s3-ui-test.tsx. It is recommended in our docs to call Amplify.configure() as early in your app as possible to avoid race-condition [Reference docs]

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending response from an Amplify UI maintainer label Apr 30, 2025
@ashika112 ashika112 added pending-community-response Issue is pending response from the issue requestor or other community members StorageBrowser question General question and removed pending-triage Issue is pending triage labels Apr 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-community-response Issue is pending response from the issue requestor or other community members question General question StorageBrowser
Projects
None yet
Development

No branches or pull requests

2 participants