Skip to content

Types

References

Visit

Re-exports Visit

VisitProps

Re-exports VisitProps

Remote

Re-exports Remote

RemoteProps

Re-exports RemoteProps

BeforeSave

Re-exports BeforeSave

Interfaces

SaveResponseAction

Extends

  • Action

Properties

Property Type Overrides Defined in
type "@@superglue/SAVE_RESPONSE" Action.type lib/types/actions.ts:6
payload {pageKey: string;page: VisitResponse; } - lib/types/actions.ts:7
payload.pageKey string - lib/types/actions.ts:8
payload.page VisitResponse - lib/types/actions.ts:9

HandleGraftAction

Extends

  • Action

Properties

Property Type Overrides Defined in
type "@@superglue/HANDLE_GRAFT" Action.type lib/types/actions.ts:14
payload {pageKey: string;page: GraftResponse; } - lib/types/actions.ts:15
payload.pageKey string - lib/types/actions.ts:16
payload.page GraftResponse - lib/types/actions.ts:17

CopyAction

Extends

  • Action

Properties

Property Type Overrides Defined in
type "@@superglue/COPY_PAGE" Action.type lib/types/actions.ts:22
payload {from: string;to: string; } - lib/types/actions.ts:23
payload.from string - lib/types/actions.ts:24
payload.to string - lib/types/actions.ts:25

RemovePageAction

Extends

  • Action

Properties

Property Type Overrides Defined in
type "@@superglue/REMOVE_PAGE" Action.type lib/types/actions.ts:30
payload {pageKey: string; } - lib/types/actions.ts:31
payload.pageKey string - lib/types/actions.ts:32

UpdateFragmentsAction

Extends

  • Action

Properties

Property Type Overrides Defined in
type "@@superglue/UPDATE_FRAGMENTS" Action.type lib/types/actions.ts:37
payload {changedFragments: Record\<string, unknown>; } - lib/types/actions.ts:38
payload.changedFragments Record\<string, unknown> - lib/types/actions.ts:39

SetCSRFToken

Extends

  • Action

Properties

Property Type Overrides Defined in
type "@@superglue/SET_CSRF_TOKEN" Action.type lib/types/actions.ts:44
payload {csrfToken: string; } - lib/types/actions.ts:45
payload.csrfToken string - lib/types/actions.ts:46

HistoryChange

Extends

  • Action

Properties

Property Type Overrides Defined in
type "@@superglue/HISTORY_CHANGE" Action.type lib/types/actions.ts:51
payload {pathname: string;search: string;hash: string; } - lib/types/actions.ts:52
payload.pathname string - lib/types/actions.ts:53
payload.search string - lib/types/actions.ts:54
payload.hash string - lib/types/actions.ts:55

BeforeVisit

Extends

  • Action

Properties

Property Type Overrides Defined in
type "@@superglue/BEFORE_VISIT" Action.type lib/types/actions.ts:65
payload {fetchArgs: [string, BasicRequestInit];currentPageKey: string; } - lib/types/actions.ts:66
payload.fetchArgs [string, BasicRequestInit] - lib/types/actions.ts:67
payload.currentPageKey string - lib/types/actions.ts:68

BeforeRemote

Extends

  • Action

Properties

Property Type Overrides Defined in
type "@@superglue/BEFORE_REMOTE" Action.type lib/types/actions.ts:73
payload {fetchArgs: [string, BasicRequestInit];currentPageKey: string; } - lib/types/actions.ts:74
payload.fetchArgs [string, BasicRequestInit] - lib/types/actions.ts:75
payload.currentPageKey string - lib/types/actions.ts:76

BeforeFetch

Extends

  • Action

Properties

Property Type Overrides Defined in
type "@@superglue/BEFORE_FETCH" Action.type lib/types/actions.ts:81
payload {fetchArgs: [string, BasicRequestInit]; } - lib/types/actions.ts:82
payload.fetchArgs [string, BasicRequestInit] - lib/types/actions.ts:83

HandleError

Extends

  • Action

Properties

Property Type Overrides Defined in
type "@@superglue/ERROR" Action.type lib/types/actions.ts:88
payload {message: string; } - lib/types/actions.ts:89
payload.message string - lib/types/actions.ts:90

GraftingSuccessAction

Extends

  • Action

Properties

Property Type Overrides Defined in
type string Action.type lib/types/actions.ts:97
payload {pageKey: string;keyPath: string; } - lib/types/actions.ts:98
payload.pageKey string - lib/types/actions.ts:99
payload.keyPath string - lib/types/actions.ts:100

GraftingErrorAction

Extends

  • Action

Properties

Property Type Overrides Defined in
type string Action.type lib/types/actions.ts:105
payload {pageKey: string;url: string;err: unknown;keyPath: string; } - lib/types/actions.ts:106
payload.pageKey string - lib/types/actions.ts:107
payload.url string - lib/types/actions.ts:108
payload.err unknown - lib/types/actions.ts:109
payload.keyPath string - lib/types/actions.ts:110

ParsedResponse

Properties

Property Type Defined in
rsp Response lib/types/index.ts:106
json PageResponse lib/types/index.ts:107

Defer

Defer is a node in the page response thats been intentionally filled with empty or placeholder data for the purposes of fetching it later.

You would typically use it with props_template for parts of a page that you know would be slower to load.

Properties

Property Type Description Defined in
url string A url with props_at keypath in the query parameter to indicate how to dig for the data, and where to place the data. lib/types/index.ts:132
type "auto" | "manual" When set to auto Superglue will automatically make the request using the url. When set to manual, Superglue does nothing, and you would need to manually use remote with the url to fetch the missing data. lib/types/index.ts:133
path string A keypath indicates how to dig for the data and where to place the data. lib/types/index.ts:134
successAction string a user defined action for Superglue to dispatch when auto deferement is successful lib/types/index.ts:135
failAction string a user defined action for Superglue to dispatch when auto deferement failed lib/types/index.ts:136

GraftResponse

The GraftResponse is a protocol, a shape that is responsible for partial updates using props_template's digging functionality in Superglue. Its meant to be implemented by the server and if you are using superglue_rails, the generators would have generated a props_template layout and view that would shape the graft responses for you.

Properties

Property Type Description Defined in
data JSONMappable - lib/types/index.ts:146
componentIdentifier string - lib/types/index.ts:147
assets string[] - lib/types/index.ts:148
csrfToken? string - lib/types/index.ts:149
fragments Fragment[] - lib/types/index.ts:150
defers Defer[] - lib/types/index.ts:151
slices JSONObject - lib/types/index.ts:152
renderedAt number - lib/types/index.ts:154
restoreStrategy RestoreStrategy - lib/types/index.ts:155
action "graft" - lib/types/index.ts:178
path string Used by superglue to replace the data at that location. lib/types/index.ts:179

Fragment

A Fragment identifies a cross cutting concern, like a shared header or footer.

Properties

Property Type Description Defined in
type string A user supplied string identifying a fragment. This is usually created using props_template lib/types/index.ts:197
path string A Keypath specifying the location of the fragment lib/types/index.ts:198

SuperglueState

A read only state that contains meta information about the current page.

Properties

Property Type Description Defined in
currentPageKey string The PageKey of the current page. This can be pass to Remote. lib/types/index.ts:213
pathname string The pathname of the current url. lib/types/index.ts:215
search string The query string of the current url. lib/types/index.ts:217
hash string The hash of the current url. lib/types/index.ts:219
csrfToken string The Rails csrfToken that you can use for forms. lib/types/index.ts:221
assets string[] The tracked asset digests. lib/types/index.ts:223

RootState

The root state for a Superglue application. It occupies 2 keys in your app.

Properties

Property Type Description Defined in
superglue SuperglueState Caontain readonly metadata about the current page lib/types/index.ts:232
pages AllPages Every PageResponse that superglue recieves is stored here. lib/types/index.ts:234

PageOwnProps

Helpful props passed to the page component.

Properties

Property Type Description Defined in
pageKey string the pagekey of the current page lib/types/index.ts:242
navigateTo (path: string, options: {action: SuggestedAction;ownProps: Record\<string, unknown>; }) => boolean - lib/types/index.ts:243
visit Visit - lib/types/index.ts:244
remote Remote - lib/types/index.ts:245

Meta

Meta is passed to the Promise when visit or remote resolves and contains additional information for navigation.

Properties

Property Type Description Defined in
pageKey string The URL of the response converted to a pageKey. Superglue uses this to persist the VisitResponse to store, when that happens. lib/types/index.ts:269
page VisitResponse The VisitResponse of the page lib/types/index.ts:271
redirected boolean Indicates if response was redirected lib/types/index.ts:273
rsp Response The original response object lib/types/index.ts:275
fetchArgs FetchArgs The original args passed to fetch. lib/types/index.ts:277
componentIdentifier string The ComponentIdentifier extracted from the response. lib/types/index.ts:279
needsRefresh boolean true when assets locally are detected to be out of date lib/types/index.ts:281
suggestedAction? SuggestedAction The SuggestedAction. This can be used for navigation. lib/types/index.ts:283

Handlers

Properties

Property Type Defined in
onClick (event: MouseEvent) => void lib/types/index.ts:327
onSubmit (event: Event) => void lib/types/index.ts:328

HistoryState

The state that is saved to history.state. Superglue stores information about the current page so that it can restore the page state when navigating back

Properties

Property Type Description Defined in
superglue true Is always true so superglue can differentiate pages that have superglue enabled or not lib/types/index.ts:348
pageKey string The page key in SuperglueState to restore from lib/types/index.ts:350
posX number The scroll position X of the page lib/types/index.ts:352
posY number The scroll position Y of the page lib/types/index.ts:354

BasicRequestInit

A variation of RequestInit except the headers must be a regular object

Extends

  • RequestInit

Properties

Property Type Description Overrides Defined in
headers? {} A Headers object, an object literal, or an array of two-item arrays to set request's headers. RequestInit.headers lib/types/index.ts:380

Type Aliases

FetchArgs

FetchArgs: [string, BasicRequestInit]

Tuple of Fetch arguments that Superglue passes to Fetch.

Defined in

lib/types/actions.ts:62


LifecycleAction

LifecycleAction: BeforeFetch | HandleError | BeforeVisit | BeforeRemote

Defined in

lib/types/actions.ts:114


PageReducerAction

PageReducerAction: SaveResponseAction | HandleGraftAction | GraftingSuccessAction | GraftingErrorAction | CopyAction | RemovePageAction | UpdateFragmentsAction

Defined in

lib/types/actions.ts:120


SuperglueReducerAction

SuperglueReducerAction: SaveResponseAction | SetCSRFToken | HistoryChange

Defined in

lib/types/actions.ts:129


AllAction

AllAction: PageReducerAction | GraftingSuccessAction | GraftingErrorAction | SuperglueReducerAction | LifecycleAction

Defined in

lib/types/actions.ts:134


PageKey

PageKey: string

A PageKey is a combination of a parsed URL's pathname + query string. No hash.

*

Example

/posts?foobar=123

Defined in

lib/types/index.ts:19


RestoreStrategy

RestoreStrategy: "fromCacheOnly" | "revisitOnly" | "fromCacheAndRevisitInBackground"

Defines the behavior when navigating to a page that is already stored on the client. For example, when navigating back.

When the page already exists in the store: - fromCacheOnly - Use the cached page that exists on the store, only. - revisitOnly - Ignore the cache and make a request for the latest page. - fromCacheAndRevisitInBackground - Use the cache version of the page so superglue can optimistically navigate to it, then make an additional request for the latest version.

Defined in

lib/types/index.ts:32


SuggestedAction

SuggestedAction: "push" | "replace" | "none"

A SuggestedAction is used to tell Superglue to history.push, history.replace or do nothing.

Defined in

lib/types/index.ts:41


NavigationAction: SuggestedAction

Defined in

lib/types/index.ts:42


ComponentIdentifier

ComponentIdentifier: string

An identifier that Superglue will uses to determine which page component to render with your page response.

Defined in

lib/types/index.ts:48


Keypath

Keypath: string

A keypath is a string representing the location of a piece of data. Superglue uses the keypath to dig for or update data.

Examples

Object access

data.header.avatar

Array access

data.body.posts.0.title

Array with lookahead

data.body.posts.post_id=foobar.title

Defined in

lib/types/index.ts:72


JSONPrimitive

JSONPrimitive: string | number | boolean | null | undefined

A JSON Primitive value

Defined in

lib/types/index.ts:79


JSONObject

JSONObject: {}

A JSON Object

Index Signature

[key: string]: JSONValue

Defined in

lib/types/index.ts:84


JSONMappable

JSONMappable: JSONValue[] | JSONObject

A JSON Object or an array of values

Defined in

lib/types/index.ts:91


JSONKeyable

JSONKeyable: JSONObject[] | JSONObject

A array of JSON key value objects or a JSON Object

Defined in

lib/types/index.ts:96


JSONValue

JSONValue: JSONPrimitive | JSONMappable

A primitive or a mappable object

Defined in

lib/types/index.ts:101


VisitResponse

VisitResponse: {data: JSONMappable;componentIdentifier: ComponentIdentifier;assets: string[];csrfToken: string;fragments: Fragment[];defers: Defer[];slices: JSONObject;renderedAt: number;restoreStrategy: RestoreStrategy; }

The VisitResponse is a protocol, a shape that is responsible for full page visits in Superglue. Its meant to be implemented by the server and if you are using superglue_rails, the generators would have generated a props_template layout and view that would shape the visit responses for you.

Type declaration

Name Type Defined in
data JSONMappable lib/types/index.ts:146
componentIdentifier ComponentIdentifier lib/types/index.ts:147
assets string[] lib/types/index.ts:148
csrfToken? string lib/types/index.ts:149
fragments Fragment[] lib/types/index.ts:150
defers Defer[] lib/types/index.ts:151
slices JSONObject lib/types/index.ts:152
renderedAt number lib/types/index.ts:154
restoreStrategy RestoreStrategy lib/types/index.ts:155

Defined in

lib/types/index.ts:145


Page

Page: VisitResponse & {savedAt: number;pageKey: PageKey; }

A Page is a VisitResponse that's been saved to the store

Type declaration

Name Type Defined in
savedAt number lib/types/index.ts:162
pageKey PageKey lib/types/index.ts:163

Defined in

lib/types/index.ts:161


PageResponse

PageResponse: GraftResponse | VisitResponse

A PageResponse can be either a GraftResponse or a VisitResponse. Its meant to be implemented by the server and if you are using superglue_rails, the generators will handle both cases.

Defined in

lib/types/index.ts:187


AllPages

AllPages: Record\<PageKey, Page>

The store where all page responses are stored indexed by PageKey. You are encouraged to mutate the Pages in this store.

Defined in

lib/types/index.ts:205


Content

Content: PageOwnProps & {[key: string]: unknown; pageKey: PageKey;fragments: Fragment[];csrfToken: string; }

Your Page's content in the data node in VisitResponse merged with additional helpers

Type declaration

Name Type Defined in
pageKey PageKey lib/types/index.ts:253
fragments Fragment[] lib/types/index.ts:254
csrfToken? string lib/types/index.ts:255

Defined in

lib/types/index.ts:252


VisitCreator()

VisitCreator: (input: string | PageKey, options: VisitProps) => MetaThunk

VisitCreator is a Redux action creator that returns a thunk. Use this to build the Visit function. Typically its already generated in application_visit.js

Parameters

Parameter Type
input string | PageKey
options VisitProps

Returns

MetaThunk

Defined in

lib/types/index.ts:292


RemoteCreator()

RemoteCreator: (input: string | PageKey, options: RemoteProps) => MetaThunk

RemoteCreator is a Redux action creator that returns a thunk. Use this to build the Remote function. Typically its already generated in application_visit.js

Parameters

Parameter Type
input string | PageKey
options RemoteProps

Returns

MetaThunk

Defined in

lib/types/index.ts:301


Dispatch

Dispatch: ThunkDispatch\<RootState, undefined, AllAction>

Defined in

lib/types/index.ts:306


SuperglueStore

SuperglueStore: EnhancedStore\<RootState, AllAction | UnknownAction, Tuple\<[StoreEnhancer\<{dispatch: Dispatch; }>, StoreEnhancer]>>

A Store created with Redux Toolkit's configureStore setup with reducers from Superglue. If you are using superglue_rails this would have been generated for you in store.js and setup correctly in application.js

Defined in

lib/types/index.ts:313


UJSHandlers()

UJSHandlers: ({ ujsAttributePrefix, visit, remote, }: {ujsAttributePrefix: string;visit: Visit;remote: Remote; }) => Handlers

Parameters

Parameter Type
{ ujsAttributePrefix, visit, remote, } object
{ ujsAttributePrefix, visit, remote, }.ujsAttributePrefix string
{ ujsAttributePrefix, visit, remote, }.visit Visit
{ ujsAttributePrefix, visit, remote, }.remote Remote

Returns

Handlers

Defined in

lib/types/index.ts:331


SaveAndProcessPageThunk

SaveAndProcessPageThunk: ThunkAction\<Promise\<void>, RootState, undefined, AllAction>

Defined in

lib/types/index.ts:357


MetaThunk

MetaThunk: ThunkAction\<Promise\<Meta>, RootState, undefined, AllAction>

Defined in

lib/types/index.ts:364


DefermentThunk

DefermentThunk: ThunkAction\<Promise\<void[]>, RootState, undefined, AllAction>

Defined in

lib/types/index.ts:371