Next.js - How to call component’s getInitialProps in Layout

Derry Berni Cahyady
1 min readJan 8, 2020

--

It’s possible call getInitialProps in layout? this answer it’s nope. But you need change method when you want load something in yout layout.

In my application i want to read cookie for all page but just once how it’s work? concept using custom app.

first u need create custom app, bypass props to your layout and read in your layout

next call as props in layout

this full code you can read here :

Thank’s

--

--

Derry Berni Cahyady
Derry Berni Cahyady

Written by Derry Berni Cahyady

Data & Security Enthusiast | Software Engineer

Responses (1)