Comments (12)
You are importing modules from different packages, which may lead to receive different instances of the Amplify object, which may not be fully configured.
In particular, if you call the .configure()
method on the Amplify instance imported directly from @aws-amplify/core
, the underlying auth providers won't be created, hence it will throw the error you have encountered. Please use the umbrella package (aws-amplify
) and avoid using the @aws-amplfiy
namespaced package unless the documentation provides instructions to do so.
from amplify-js.
Ran into this same issue during migration from v5 to v6 and I guess my use case is similar to that of @aoneahsan. i.e. Using a pre-existing AWS Cognito instance for auth with the least amount of configuration and reliance on Amplify.
I can confirm that using only the aws-amplify
package in the dependency management and replacing
import { Amplify, AuthUserPoolConfig, ResourcesConfig } from '@aws-amplify/core';
with
import { AuthUserPoolConfig, ResourcesConfig } from '@aws-amplify/core';
import { Amplify } from 'aws-amplify';
worked exactly as described above (i.e. avoiding partially configured providers) and did not significantly affect the bundle size, even with development generated bundles.
from amplify-js.
@aoneahsan got it. The recommended usage is to import the api's from aws-amplify
so it should be working as expected.
Did you have concerns with this? Im looking to understand why you are wanting to use @aws-amplify/core
+ @aws-amplify/auth
- for example are you looking for bundle size improvements?
from amplify-js.
yes, i want to use these packages so it will improve the final bundle size
from amplify-js.
@aoneahsan, we don't have any resources to share on this because we don't recommend this (as @HuiSF mentioned above). However, this would be the list of categories within Amplify that would utilize the @aws-amplify
pattern if you're looking to improve the installation size:
- geo
- interactions
- predictions
- pubsub
- adapter-nextjs
- datastore-storage-adapter
from amplify-js.
HI @aoneahsan thank you for openning this issue. Could you clarify why you are installing both "aws-amplify" and "@aws-amplify/core" + "@aws-amplify/auth" packages? You should only need to install aws-amplify
, then import the api's from it.
from amplify-js.
basically i wanted to use
@aws-amplify/core + @aws-amplify/auth
that did not work that's why i had to use this aws-amplify
from amplify-js.
@aoneahsan bundle size should not be a problem because the library supports tree shaking capabilities, if you are using a modern bundler (like webpack) it should only include the part of the library you are importing.
from amplify-js.
okay, but let's focus on why it's giving error when tried with @aws-amplify/auth package?
from amplify-js.
@aoneahsan, have you had a chance to review the above comments? Just want to check in and see if there are still any concerns at this point. Thanks.
from amplify-js.
I'm using "aws-amplify" package right now and it's working.
but i want to know how to use "@aws-amplify" packages properly
please do share any official resource example showing the process
from amplify-js.
It looks like we can call this issue resolved then at this point. If anyone following this still has questions or experiencing a further blocker tied to this, feel free to reply back and we can reopen.
from amplify-js.
Related Issues (20)
- Access Denied (403) executing downloadData() despite allow.guest.to(['read']) HOT 9
- I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- Auth v6 - How to respond to challenge_answer after redirecting back from Duo Security's URL? HOT 2
- V3 to V6 upgrade causes AuthUserPoolException HOT 6
- Access Denied when trying to access a resource from S3 HOT 8
- Can't send AWSJSON array values using aws-amplify and graphql HOT 3
- Unable to build RN iOS , Errror: /Build/Products/Debug-iphonesimulator/AmplifyRTNCore/AmplifyRTNCore.modulemap' not found HOT 3
- V6 - Not be able to sign in automatically with Federation HOT 17
- Amplify v6 Storage - ExpiredToken After 1 Hour Upload HOT 3
- Rest API: Providing an "x-api-key" is mutually exclusive with signing the request HOT 3
- codegen models import results in errors
- Export Cognito errors so developers can easily reference them in our code HOT 3
- React Native - @aws-amplify/rtn-push-notification - Could not find org.jetbrains.kotlin:kotlin-serialization-compiler-plugin-embeddable:1.8.0 - Upgrading React native 0.73 > 0.74 HOT 4
- AWS amplify Predictions Text-to-Speech Error in react native cli HOT 2
- fetchAuthSession(): credentials / sessionToken Not Persisted Across Restarts HOT 3
- (storage) getUrl should support contentDisposition (again; used to) HOT 2
- Cognito Identity API Call made even when auth is explicitly passed in HOT 5
- Update to Amplify Console now fails to build across environments HOT 2
- SignInWithRedirect a custom provider returns authorization_code and state but doesn't login the user - v6 HOT 3
- InvalidParameterException: Invalid SourceUser: Cognito users with a username/password may not be passed in as a SourceUser, only as a DestinationUser HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amplify-js.