docs
  1. Developer Guide
  2. Technical Foundation
  3. Hooks

Hooks

The @scayle/storefront-nuxt provides Nitro runtime hooks, allowing you to extend the NPM package functionality by executing custom logic during specific events.

Compared to overriding RPCs with a custom implementation, hooks offer a less intrusive way to extend RPC logic without fully redefining existing behavior. These hooks can be registered within a Nitro plugin in your Storefront Application.

Example

HookArgumentsDescription
storefront:context:createdrpcContextCalled after the rpcContext has been initialized and created.
storefront:rpc:beforerpcName, rpcContext, rpcPayloadCalled before an RPC method is executed.
storefront:rpc:afterrpcName, rpcContext, rpcResultCalled after an RPC method has been successfully executed.
storefront:rpc:errorrpcName, rpcContext, errorCalled when an error is thrown during the execution of an RPC method.
storefront:afterLogin{ shopId, user, authenticationType, accessToken }, rpcContextCalled after a user has successfully logged in.
storefront:afterLogout{ shopId, user, authenticationType }, rpcContextCalled after a user has successfully logged out.