Been running into a couple of issues trying to setup reduxt toolkit in next 14 as see n below. i've followed the exact steps on several youtube videos and articles online. but stil getting stuck here as i can't wrap my head around what seems to be the issue
when it get's compiled by next on the frontend i get this error
and this is the store.ts file
In next.js, you have to créate a providers file, and import it for using in layout. Something like this:
// Providers.js
'use client';
import { Provider } from "react-redux";
import { store } from "./store";
import { Providers } from "@/Redux/provider"
export function Providers({ children }) {
return <Provider store={store}>{children}</Provider>;
}
Now in your layout.js, import and use it:
import { Inter } from "next/font/google";
import "./globals.css";
import { Providers } from "@/Redux/provider"
const inter = Inter({ subsets: ["latin"] });
export const metadata = {
title: "Your App",
description: "This is a example for use redux in next.js versión 13 >=",
};
export default function RootLayout({ children }) {
return (
<Providers store={store}>
<html lang="en">
<body className={inter.className}>
<Header />
{children}
</body>
</html>
</Providers>
);
}
In the example, I créate a folder Redux for settings and files.
I hope to help you. =)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With