User Auth Installation
Version: 2.1.1 | 6 containers
Step-by-step
Use the following steps to install the User Auth component:
Install the packages
Install the required packages using npm:
npm install @dropins/tools @dropins/storefront-authMap the packages
Add the drop-in to your importmap in the head.html file:
<script nonce="aem" type="importmap">{ "imports": { "@dropins/storefront-auth/": "/scripts/__dropins__/@dropins/storefront-auth/", "@dropins/tools/": "/scripts/__dropins__/tools/" }}</script>With the importmap defined, you can now import the required files from these packages into your block as described in the next step.
Import the required files
Import the necessary components and utilities:
// GraphQL Clientimport * as mesh from '@dropins/tools/fetch-graphql.js';
// Component toolsimport { initializers } from '@dropins/tools/initializer.js';
// Drop-in component providerimport { render as provider } from '@dropins/storefront-auth/render.js';
// Drop-in component API functionsimport * as api from '@dropins/storefront-auth/api.js';
// Drop-in component containersimport { AuthCombine } from '@dropins/storefront-auth';Connect to the endpoint
Configure the GraphQL endpoint:
// Set endpoint configurationmesh.setEndpoint('https://<graphql-service-endpoint>/graphql');
// Set store code headermesh.setFetchGraphQlHeader('store', '<default>');Register and load the drop-in
Mount the initializers after the page has loaded:
// Register drop-in initializerinitializers.register(api.initialize, {});
// Mount initializers (must be called after all initializers are registered)initializers.mountImmediately(initialize, { langDefinitions });Render the drop-in
Render the AuthCombine container on your page:
// Render User Authprovider.render(AuthCombine, { // Add configuration options here})(document.getElementById('your-dropin-element'));Next steps
- Explore the [API functions](/dropins/User Auth/functions/) available for programmatic control
- Customize the appearance using [slots](/dropins/User Auth/slots/)
- Learn about [events](/dropins/User Auth/events/) for integration with other components