Context

List of all the available keys in context:

Key Type Available Description
app Root Vue Instance Client & Server The root Vue instance that includes all your plugins. For example, when using axios, you can get access to $axios through context.app.$axios.
isClient Boolean Client & Server Boolean to let you know if you're actually renderer from the client-side (deprecated. use process.client).
isServer Boolean Client & Server Boolean to let you know if you're actually renderer from the server-side (deprecated. use process.server).
isStatic Boolean Client & Server Boolean to let you know if you're actually inside a generated app (via nuxt generate) (deprecated. use process.static).
isDev Boolean Client & Server Boolean to let you know if you're in dev mode, can be useful for caching some data in production.
isHMR Boolean Client & Server Boolean to let you know if the method/middleware is called from webpack hot module replacement (only on client-side in dev mode).
route Vue Router Route Client & Server Vue Router route instance.
store Vuex Store Client & Server Vuex Store instance. Available only if the vuex store is set.
env Object Client & Server Environment variables set in nuxt.config.js, see env api.
params Object Client & Server Alias of route.params.
query Object Client & Server Alias of route.query.
req http.Request Server Request from the Node.js server. If Nuxt is used as a middleware, the req object might be different depending of the framework you're using.
Not available via nuxt generate.
res http.Response Server Response from the Node.js server. If Nuxt is used as a middleware, the res object might be different depending of the framework you're using.
Not available via nuxt generate.
redirect Function Client & Server Use this method to redirect the user to another route, the status code is used on the server-side, default to 302. redirect([status,] path [, query]).
error Function Client & Server Use this method to show the error page: error(params). The params should have the properties statusCode and message.
nuxtState Object Client Nuxt state, useful for plugins which uses beforeNuxtRender to get the nuxt state on client-side before hydration. Available only in universal mode.
beforeNuxtRender(fn) Function Server Use this method to update __NUXT__ variable rendered on client-side, the fn (can be asynchronous) is called with { Components, nuxtState }, see example.

Caught a mistake or want to contribute to the documentation? Edit this page on GitHub!