How to read from a file in custom App component in next.js

151 views Asked by At

I have a requirement to read a file in _app component and pass its content through a provider to make it available to the whole application.

The project is using antd for components and emotions for styling. Since antd uses less for styling, we wanted to declare global variables in a single less file then using less-vars-to-js convert and share it via emotion's ThemeProvider to make use of them in the whole application. Also want to share the antd dark and light themes with emotion for dynamic theme switch.

In next.js we can read files in getStaticProps, but that is not available to be used in the _app component and getInitialProps doesn't seem to work for this either.

Is there any way to achieve this?

Thanks!

0

There are 0 answers