Returns the WixRouterResponse
object with a status code 200 (OK) and instructs the router to show the selected page.
The ok()
function is used in the router()
and afterRouter()
hooks to continue the routing process to the specified page with a successful
HTTP response code. The specified page must be a page found under the given router
in the Page Code section of the Code sidebar. For example, if you want to route to myRouter-page from
the myRouter_Router()
function, myRouter-page must be in the MyRouter Pages (Router)
section of your site's Code sidebar.
Optionally, you can pass the routerReturnedData
object to be used by the
page routed to and the head
options object for the page. The page routed to accesses the
data passed to it using the getRouterData()
function of wix-window-frontend
with optional data and HTML header.
For enhanced performance, you can also pass a cache
object in the options
parameter to temporarily store the return value of the ok()
function for a specified duration. This reduces response times and eliminates the need to repeatedly fetch data. You can set the duration, in seconds, for which you want the return value to be cached. The default is approcimately 1 week.
Assign identifiers to your caches using the tags
property of the cache
object. Tags allow you to specify cached return values that may later require invalidation due to a significant change in your data. To invalidate your caches, use the invalidateCache()
function from the wix-cache-backend
module. Once invalidated, the return value will be re-cached the next time the request is made.
Important:
The tags
property is required for caching. Without tags, nothing is cached.
A router page or an array of page fallbacks.
A data object.
HTML head members of the response.
Router caching options.