Ember Cognito Integration
ember-cognito is an Ember Addon that integrates the Ember.js authentication library, ember-simple-auth, with AWS Amplify and AWS Cognito User Pools. It provides a custom authenticator and a service to access Amplify authentication methods, streamlining user authentication in Ember applications using AWS's managed identity service. The current stable version is 4.0.2, released in December 2025. This addon has a consistent release cadence, frequently updating to support newer Ember.js and AWS Amplify versions. A key differentiator is its seamless integration with ember-simple-auth, abstracting the complexities of interacting directly with the AWS Cognito SDK via Amplify, and providing helpers for common authentication flows like sign-up, confirmation, and session management. It also requires specific configuration for modern Ember v2 addons and Embroider compatibility.
Common errors
-
Could not find module `ember-cognito/registry`
cause Attempting to build or run an Ember application using `ember-cognito` v4.x without configuring the v2 addon registry.fixIn your `ember-cli-build.js` or `app.js`, add `import emberCognitoRegistry from 'ember-cognito/registry';` and spread `...emberCognitoRegistry()` into your `modules` configuration. -
Error: Cannot find module 'ember-simple-auth/mixins/data-adapter-mixin'
cause Your application has `ember-cognito` installed (>=v2.0.0) but is missing `ember-simple-auth` as a direct dependency or has an incompatible version.fixRun `npm install ember-simple-auth@latest` or `yarn add ember-simple-auth@latest` to ensure `ember-simple-auth` is installed and meets the `ember-cognito` peer dependency requirements. -
Node.js vX.Y.Z is not supported. Please use Node.js v16 or higher.
cause Running an Ember CLI project with `ember-cognito` v2.0.0 or higher on an unsupported Node.js version.fixUpgrade your Node.js environment to version 16 or newer. -
Missing credentials in config or authentication flow type
cause The `cognito` configuration in `config/environment.js` is missing `poolId` or `clientId`, or the specified `authenticationFlowType` is invalid.fixVerify that `ENV.cognito.poolId` and `ENV.cognito.clientId` are correctly set in `config/environment.js`. Check the `authenticationFlowType` against allowed values (`USER_SRP_AUTH | USER_PASSWORD_AUTH`).
Warnings
- breaking Version 4.0.0 converted `ember-cognito` to an Ember v2 addon, which requires explicit registry setup in your application's `ember-cli-build.js` or `app.js` file. Failing to do so will result in module resolution errors.
- breaking `ember-cognito` v4.0.0 updated the underlying AWS Amplify/Cognito SDK to v6.x. This may introduce breaking changes or require updates to how you interact with Amplify directly if your application uses it outside of `ember-cognito`'s provided services.
- breaking Version 2.0.0 dropped support for Node.js versions below 16. Applications running on older Node.js environments will fail to build or run correctly.
- breaking In v2.0.0, `ember-simple-auth` was changed from a direct dependency to a peer dependency. Ensure you have `ember-simple-auth` installed in your project at a compatible version (>= 8.0.0).
- breaking Version 0.10.0-beta.0 (and subsequent 0.10.0 stable) replaced direct AWS Cognito SDK usage with AWS Amplify. This was a significant internal change that removed the `CognitoStorage` object and altered how tokens are managed, making existing direct Cognito SDK integrations incompatible.
- gotcha The Cognito JavaScript SDK requires that your Cognito App Client be created without a client secret. Attempting to use a client with a secret will lead to authentication failures.
Install
-
npm install ember-cognito -
yarn add ember-cognito -
pnpm add ember-cognito
Imports
- Cognito Authenticator
import { Cognito } from 'ember-cognito/authenticators/cognito';import Authenticator from 'ember-cognito/authenticators/cognito';
- Cognito Service
import { cognito } from 'ember-cognito/services/cognito';import { service } from '@ember/service'; class MyComponent { @service cognito; } - emberCognitoRegistry
import emberCognitoRegistry from 'ember-cognito/registry';
Quickstart
import Component from '@ember/component';
import { action } from '@ember/object';
import { service } from '@ember/service';
import { tracked } from '@glimmer/tracking';
// Ensure your config/environment.js has:
// cognito: {
// poolId: "<your Cognito User Pool ID>",
// clientId: "<your Cognito App Client ID>",
// },
export default class LoginComponent extends Component {
@service session;
@tracked username = '';
@tracked password = '';
@tracked errorMessage = '';
@action
updateUsername(event) {
this.username = event.target.value;
}
@action
updatePassword(event) {
this.password = event.target.value;
}
@action
async authenticate() {
this.errorMessage = ''; // Clear previous errors
try {
await this.session.authenticate('authenticator:cognito', {
username: this.username,
password: this.password
});
// Authentication successful, redirect or update UI
console.log('User authenticated successfully!');
} catch (error) {
this.errorMessage = error.message || String(error);
console.error('Authentication error:', this.errorMessage);
}
}
// Example of using the cognito service for signup
@service cognito;
@tracked signUpUsername = '';
@tracked signUpPassword = '';
@tracked signUpEmail = '';
@tracked signUpSuccess = false;
@action
async signUp() {
this.errorMessage = '';
try {
await this.cognito.signUp(
this.signUpUsername,
this.signUpPassword,
{ email: this.signUpEmail }
);
this.signUpSuccess = true;
console.log('Sign-up successful, check email for confirmation code.');
} catch (error) {
this.errorMessage = error.message || String(error);
console.error('Sign-up error:', this.errorMessage);
}
}
}