window.localStorage function not working on API Routing NextJS

How to can use window syntax on API Route NextJS?

export async function POST(request: NextApiRequest, response: NextApiResponse<DataResponse>) {
    const dataReq = await request.json();
    window.localStorage('cachestore', JSON.stringify(dataReq));
}

The function window on POST or GET in the Next JS Routing API does not work. However, on a regular page it can run using the useEffect()=>{} function. How can I make it work well when accessing the /api/page page?