Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

180
Visualizações
How to get cookies in _app.js in next js

I want to get cookies in _app.js in next js but I cant and it always return undefined is there a way to solve this problem also a lot of people are saying you should use getInitialProps but in the documentation, it says it is not recommended

here is my _app.js

import "tailwindcss/tailwind.css";
import Navbar from "../components/Navbar.js"

function MyApp({ Component, pageProps, token }) {
  return (
   <Navbar token={token} />
   <Component {...pageProps} />;
  )
}

export default MyApp;

export const getServerSideProps = ({ req, res }) => {
  return {
    props: {
      token: req.cookies.token,
    },
  };
};

I am trying to access the navbar in _app.js and get the cookie token but it always returns undefined but when I do it elsewhere like index.js it works completely fine

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda