The Util Directory
The util directory in ScandiPWA contains various utility functions that don't belong in the other categories
Some Util directories, such as Address, Cart, Currency, Menu, Price, Product, facilitate working with certain kinds of data. Others define commonly-needed functionality:
Responsible for user authentication
Convenience methods for accessing the browser's local storage with a simpler API
CSS manipulation. E.g. an utility for setting a CSS variable. This is useful if you want to be able to dynamically edit theme colors from the admin panel.
Implements a part of the plugin mechanism
Works with form data
Utility for working with media URLs
Function that helps determine the browser device, and wether it is a mobile device.
Implements a cancelable promise
Defines tools to work with GraphQL queries
Defines tools to work with Requests
Tools to work with URLs and parse them.
Finally, there is the
Braintreedirectory, which can handle interaction with the Braintree payment method.
When overriding the theme or creating plugins, you are allowed to override Util files to add functionality, or to create your own Util files.