'Is there any way to use redux toolkit inside getStaticProps in Next.js?

I get the data when I use useEffect instead of getStaticProps. But in getStaticProps it's showing that hooks can only be use in functional component.

import Head from 'next/head'
import Image from 'next/image'
import Sidebar from '../components/Sidebar'
import styles from "../styles/Home.module.css"
import CssBaseline from '@mui/material/CssBaseline'
import Navbar from '../components/Navbar'
import Mainbody from '../components/Mainbodi'
import { useGetCryptosQuery } from '../services/CryptoApi'

export default function Homee({res}) {
   console.log(res);
   return (
      <div>
         <div className={styles.container}>
            <CssBaseline />
            <Sidebar/>
            <div className={styles.bodi}>
               <Navbar/>
               <Mainbody/>
            </div>
         </div>
       </div>
   )
}

export const getStaticProps = async() => {
   const {data, isFetching} = await useGetCryptosQuery()
   return {
      props: {
         res: data.data.coins
      }
   }
}


Solution 1:[1]

With the release of RTK query version 1.7, support for SSR is available. Although, according to the official docs, you need to setup next-redux-wrapper first.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nariman Rajabi