---
title: "Discussion on \"Using localStorage in React and Next.js\" | Hashnode"
description: "Discussion on \"Using localStorage in React and Next.js\". We can't directly access localStorage in React and Next.js. So, for that purpose, here is the custom react hook, that will allow you to access localStorage.\nimport { useEffect, useState } from \"react\";\n\nexport function useLocalStorage<T>(key: string,..."
url: "https://hashnode.com/posts/using-localstorage-in-react-and-nextjs/6373cca03d86fdeac94d709f"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Using localStorage in React and Next.js](https://cb-ashik.hashnode.dev/using-localstorage-in-react-and-nextjs?utm_source=hashnode&utm_medium=feed)

We can't directly access localStorage in React and Next.js. So, for that purpose, here is the custom react hook, that will allow you to access localStorage. import { useEffect, useState } from "react"; export function useLocalStorage<T>(key: string,...

Nov 15, 2022 · 1 min read · cb-ashik.hashnode.dev  
Read the article

-   [#uselocalstorage](https://hashnode.com/tag/uselocalstorage)
-   [#reactjs](https://hashnode.com/tag/reactjs)
-   [#nextjs](https://hashnode.com/tag/nextjs)
-   [#hooks](https://hashnode.com/tag/hooks)
-   [#localstorage](https://hashnode.com/tag/localstorage)

## Written by

[Ashik Chapagain](https://hashnode.com/@chapagainashik)

@chapagainashik · Pokhara, Nepal

  
[View profile](https://hashnode.com/@chapagainashik)

17\. Nepal. Full Stack Web Developer

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
