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

320
Visualizações
Document is not defined - Mapbox

I am trying to put the latest version of @mapbox/search-js-react version 1.0.0-beta.12 into my nextjs application however when I do I get the following error.

Server Error ReferenceError: document is not defined This error happened while generating the page. Any console logs will be displayed in the terminal window.

Now the logs show the following

Call Stack Object.

file:///Users/USERNAME/Node_Projects/(APP)/node_modules/@mapbox/search-js-web/dist/index.js (1:1939)

Here is the code below.

import { getSession, signOut } from 'next-auth/react';
import { useState, useEffect } from 'react';
import { AddressAutofill } from '@mapbox/search-js-react';
import Dashboard from '../../../components/layout/dashboard';
import { Container, Button, Table } from 'react-bootstrap';

export default function Details({ signOOut }) {
  if (signOOut == true) {
    signOut();
  }

  //    const [data, setData] = useState(null)
  //    const [isLoading, setLoading] = useState(false)

  return (
    <form>
      <AddressAutofill accessToken='pk.eyJ1IjoicnVzc2VsbGhhcnJvd2VyIiwiYSI6ImNsMzhiYzZ5YjFqbzUzZnFzeXU1MnNjaTYifQ.baPPgnI_Vxxu0mS32DDs3w'>
        <input
          name='address'
          placeholder='Address'
          type='text'
          autoComplete='address-line1'
        />
      </AddressAutofill>
      <input
        name='apartment'
        placeholder='Apartment number'
        type='text'
        autoComplete='address-line2'
      />
      <input
        name='city'
        placeholder='City'
        type='text'
        autoComplete='address-level2'
      />
      <input
        name='state'
        placeholder='State'
        type='text'
        autoComplete='address-level1'
      />
      <input
        name='country'
        placeholder='Country'
        type='text'
        autoComplete='country'
      />
      <input
        name='postcode'
        placeholder='Postcode'
        type='text'
        autoComplete='postal-code'
      />
    </form>
  );
}

export async function getServerSideProps(ctx) {
  const Gsession = await getSession(ctx);

  var signo = false;
  console.log('Checking Session are : ' + JSON.stringify(Gsession));
  if (Gsession) {
    if (Gsession.error == 555) {
      signo = true;
    }
  }

  return {
    props: {
      sessions: Gsession,
      signOOut: signo,
    },
  };
}

Details.auth = true;

Details.getLayout = function getLayout(page) {
  return <Dashboard>{page}</Dashboard>;
};
about 4 years ago · Santiago Gelvez
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