User Account initialization
The User Account initializer configures user account management features including profile editing, address management, and account settings. Use initialization to customize account data models and user interface behaviors.
Configuration options
Section titled “Configuration options”The following table describes the configuration options available for the User Account initializer:
| Parameter | Type | Req? | Description |
|---|---|---|---|
langDefinitions | LangDefinitions | No | Language definitions for internationalization (i18n). Override dictionary keys for localization or branding. |
models | Record<string, any> | No | Custom data models for type transformations. Extend or modify default models with custom fields and transformers. |
authHeaderConfig | authHeaderConfig | No | Configures authentication header format for API requests including custom header names and token prefix format (e.g., ‘Bearer’, ‘Token’). |
Default configuration
Section titled “Default configuration”The initializer runs with these defaults when no configuration is provided:
import { initializers } from '/@dropins/tools/initializer.js';import { initialize } from '@dropins/storefront-account';
// All configuration options are optionalawait initializers.mountImmediately(initialize, { langDefinitions: {}, // Uses built-in English strings models: {}, // Uses default data models // Drop-in-specific defaults: // authHeaderConfig: undefined // See configuration options below});Language definitions
Section titled “Language definitions”Override dictionary keys for localization or branding. The langDefinitions object maps locale keys to custom strings that override default text for the drop-in.
import { initializers } from '/@dropins/tools/initializer.js';import { initialize } from '@dropins/storefront-account';
const customStrings = { 'AddToCart': 'Add to Bag', 'Checkout': 'Complete Purchase', 'Price': 'Cost',};
const langDefinitions = { default: customStrings,};
await initializers.mountImmediately(initialize, { langDefinitions });Customizing data models
Section titled “Customizing data models”Extend or transform data models by providing custom transformer functions. Use the models option to add custom fields or modify existing data structures returned from the backend.
Available models
Section titled “Available models”The following models can be customized through the models configuration option:
| Model | Description |
|---|---|
OrderHistoryModel | Transforms OrderHistoryModel data from GraphQL. |
CustomerDataModelShort | Transforms CustomerDataModelShort data from GraphQL. |
The following example shows how to customize the OrderHistoryModel model for the User Account drop-in:
import { initializers } from '/@dropins/tools/initializer.js';import { initialize } from '@dropins/storefront-account';
const models = { OrderHistoryModel: { transformer: (data) => ({ // Add custom fields from backend data customField: data?.custom_field, promotionBadge: data?.promotion?.label, // Transform existing fields displayPrice: data?.price?.value ? `${data.price.value}` : 'N/A', }), },};
await initializers.mountImmediately(initialize, { models });Drop-in configuration
Section titled “Drop-in configuration”The User Account initializer configures user account management features including profile editing, address management, and account settings. Use initialization to customize account data models and user interface behaviors.
import { initializers } from '/@dropins/tools/initializer.js';import { initialize } from '@dropins/storefront-account';
await initializers.mountImmediately(initialize, { langDefinitions: {}, authHeaderConfig: {}, models: {},});Configuration types
Section titled “Configuration types”The following TypeScript definitions show the structure of each configuration object:
authHeaderConfig
Section titled “authHeaderConfig”Configures authentication header format for API requests including custom header names and token prefix format (e.g., ‘Bearer’, ‘Token’).
authHeaderConfig?: { header?: string; tokenPrefix?: string; }langDefinitions
Section titled “langDefinitions”Maps locale identifiers to dictionaries of key-value pairs. The default locale is used as the fallback when no specific locale matches. Each dictionary key corresponds to a text string used in the drop-in UI.
langDefinitions?: { [locale: string]: { [key: string]: string; };};models
Section titled “models”Maps model names to transformer functions. Each transformer receives data from GraphQL and returns a modified or extended version. Use the Model<T> type from @dropins/tools to create type-safe transformers.
models?: { [modelName: string]: Model<any>;};Model definitions
Section titled “Model definitions”The following TypeScript definitions show the structure of each customizable model:
OrderHistoryModel
Section titled “OrderHistoryModel”export interface OrderHistoryModel { items: OrderDetails[]; pageInfo: PaginationInfo; totalCount: number; dateOfFirstOrder: string;}CustomerDataModelShort
Section titled “CustomerDataModelShort”export interface CustomerDataModelShort { firstName: string; lastName: string; middleName: string; dateOfBirth: string; prefix: string; gender: 1 | 2 | string; suffix: string; email: string; createdAt: string; [key: string]: string | boolean | number;}