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

254
Visualizações
Setting up NextJS App with Redux Store outside of application directory

I'm trying to setup a NextJS app with an already configured Redux store.

The Redux store lives in the parent directory of the app, stored in a common folder with the store, actions, reducers, sagas etc. This is so that when handling global state on an application (Web & Mobile app), all files relating to the Redux Store are configured once and shared across all platforms (since we are also using Redux Sagas to asynchronously fetch data and update state accordingly) as opposed to creating multiple copies of the same Redux store, the same actions, reducers and sagas for each application.

This is my _app.tsx file:

import type { AppProps } from 'next/app'

/* 
SETUP REDUX STORE, REDUX SAGAS, REDUX PERSIST SO THAT CWP CAN GLOBALLY MANAGE STATE,
HANDLE STATE ASYNCHRONOUSLY AND PERSIST STORE IN BROWSERS LOCALSTORAGE
*/

import { Provider } from 'react-redux'
import { PersistGate } from 'redux-persist/integration/react'
import _store from '../../common/store'

function MyApp({ Component, pageProps }: AppProps) {
  const { store, persistor } = _store()

  return (
    <Provider store={store}>
      <PersistGate loading={null} persistor={persistor}>
        <Component {...pageProps} />
      </PersistGate>
    </Provider>
  )
}

export default MyApp

The error I receive when attempting to run my application on localhost:3000 is

Module parse failed: Unexpected token (13:37)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| let _persistor
| 
> export default function (initialState: AppState = {}, forceNewStore?: boolean) {
|   // It's very important to only return the cached store on the client, otherwise SSR will return the previous request state
|   // @ts-ignore

I believe this error is caused because I am trying to use a file outside of the applications directory (_store from '../../common/store.ts')

How would I setup my NextJS config to use this already configured Redux file?

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