Handling cookies
Thanks to the preinstalled cookie-universal-nuxt (opens new window) package, we can easily handle cookies from both components and middlewares.
Handling cookies in components:
<script>
import { useContext } from '@nuxtjs/composition-api';
export default {
setup () {
const { $cookies } = useContext();
// `$cookies.get()` or `$cookies.set()`
}
};
</script>
Handling cookies in middlewares:
export default ({ $cookies }) => {
// `$cookies.get()` or `$cookies.set()`
};