Web Fragments full API reference

Last updated: December 8, 2024

Full API Reference

Fragment Gatway API reference

For usage go to the gateway document.

MemberTypeDescription
#private(private)Internal private property (implementation details are hidden).
fragmentConfigs(private)Internal storage for fragment configurations.
routeMap(private)Internal mapping of routes for fragment handling.
Constructorconstructor(config?: FragmentGatewayConfig)Initializes a new instance of the FragmentGateway class. Accepts an optional configuration object (FragmentGatewayConfig).
prePiercingStylesstringReturns a string representing styles applied before piercing fragments.
registerFragment(fragmentConfig: FragmentConfig): voidMethodRegisters a fragment in the gateway worker for integration with the gateway worker.
Parameters:
  • fragmentConfig: Configuration object for the fragment.
`matchRequestToFragment(urlOrRequest: stringURLRequest): FragmentConfig

Fragment configuration object and API reference

PropertyTypeDescription
fragmentIdstringUnique Id for the fragment.
prePiercingClassNamesstring[]Styles to apply to the fragment before it gets pierced. Their purpose is to style the fragment to look as close as possible to the final pierced view, ensuring the piercing operation appears seamless. For best results, use the following selector: :not(piercing-fragment-outlet) > piercing-fragment-host[fragment-id="fragmentId"].
routePatternsstring[]An array of route patterns this fragment should handle serving. Pattern format must adhere to path-to-regexp syntax.
upstreamstringThe upstream URI of the fragment application. This will be fetched for any request paths matching the specified routePatterns.
forwardFragmentHeaders?string[]An optional list of fragment response headers to forward to the gateway response.
onSsrFetchError?`(req: RequestInfo, failedResOrError: Responseunknown) => SSRFetchErrorResponse