Reference
Context
This object is sent to asyncData()
function in your pages components,
to onHttpRequest
store action, to the exported src/main.js
initialization function
and to your defined middlewares.
Variable name | Type | Description |
---|---|---|
app | Vue instance | The main component of the application |
router | Vue router instance | Router of the application. Official docs |
store | Vuex instance | Vuex store. Official docs |
route | Route | The current route object. See: Route Object |
params | Object | Alias of route.params |
query | Object | Alias of route.query |
redirect | Function | Simple function to redirect to a specific page. Docs |
error | Function | Simple function to display an error page: Docs |
url | String | URL of current page. SSR only |
ctx | Koa context | The current koa context. See Koa website. SSR only |
TIP
This variables are also accessible from this.$context
in your components
Process variables
Thanks to Webpack and his DefinePlugin, this starter inject some useful variables in your project to handle some conditions based on build or environment context.
List of defined variables :
Variable name | Description |
---|---|
process.dev | Return true in development mode, false otherwise |
process.test | Is true if in test environment |
process.prod | Return true in production mode, false otherwise |
process.spa | Return true in SPA mode, false in SSR mode |
process.ssr | Return true in SSR mode, false in SPA mode |
process.client | In SSR mode only: return true if in client rendering, false if in server side rendering |
process.server | In SSR mode only: return true if in server side rendering, false otherwise |
TIP
For environment variables see the official Vue CLI documentation
Configuration
Theses configuration are in neue.config.js
in your root project folder.
Here is defaults values :
module.exports = {
ssr: {
server: null,
directives: {},
https: null,
// See: https://ssr.vuejs.org/api/#shouldpreload
shoudPrefetch: null,
shoudPreload: null,
},
generate: {
paths: [],
scanRouter: true,
params: {},
},
templatePath: 'src/index.html',
paths: {
main: '@/main',
store: '@/store',
router: '@/router',
},
css: {
extract: false,
},
plugins: {},
};