Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

251
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda