<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/PSqY2FkEL" -->

---
title: LocalStorage vs. Cookies: All You Need to Know About...
description: JWT Tokens are awesome but how do you store them securely in your front-end? We’ll go over the pros and cons of localStorage and Cookies. Local storage is...
canonical: https://daily.dev/posts/localstorage-vs-cookies-all-you-need-to-know-about-storing-jwt-tokens-securely-in-the-front-end-psqy2fkel
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: LocalStorage vs. Cookies: All You Need to Know About Storing JWT Tokens Securely in the Front-End | daily.dev
og:description: JWT Tokens are awesome but how do you store them securely in your front-end? We’ll go over the pros and cons of localStorage and Cookies. Local storage is...
og:url: https://daily.dev/posts/localstorage-vs-cookies-all-you-need-to-know-about-storing-jwt-tokens-securely-in-the-front-end-psqy2fkel
og:image: https://api.daily.dev/og/posts/PSqY2FkEL.png
og:image:alt: LocalStorage vs. Cookies: All You Need to Know About Storing JWT Tokens Securely in the Front-End
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# LocalStorage vs. Cookies: All You Need to Know About Storing JWT Tokens Securely in the Front-End

**[codeburst](https://daily.dev/sources/codeburst)** · 5 min read · 27 upvotes · 1 comments

## Summary

JWT Tokens are awesome but how do you store them securely in your front-end? We’ll go over the pros and cons of localStorage and Cookies. Local storage is vulnerable because it’s easily accessible using JavaScript and an attacker can retrieve your access token and use it later.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://codeburst.io/localstorage-vs-cookies-all-you-need-to-know-about-storing-jwt-tokens-securely-in-the-front-end-70dc0a9b3ad3>

## Community discussion

Top comments from developers on daily.dev.

**@idoshamun** · 0 upvotes

> I encourage you to read the article but the rule of thumb is to save access token in memory and refresh token in a cookie

---

Tags: [#webdev](https://daily.dev/tags/webdev), [#security](https://daily.dev/tags/security), [#javascript](https://daily.dev/tags/javascript), [#cyber](https://daily.dev/tags/cyber), [#authentication](https://daily.dev/tags/authentication)

[View this post on daily.dev](https://daily.dev/posts/localstorage-vs-cookies-all-you-need-to-know-about-storing-jwt-tokens-securely-in-the-front-end-psqy2fkel)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"LocalStorage vs. Cookies: All You Need to Know About Storing JWT Tokens Securely in the Front-End","url":"https://daily.dev/posts/localstorage-vs-cookies-all-you-need-to-know-about-storing-jwt-tokens-securely-in-the-front-end-psqy2fkel","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/localstorage-vs-cookies-all-you-need-to-know-about-storing-jwt-tokens-securely-in-the-front-end-psqy2fkel"},"datePublished":"2020-09-09T01:10:19.751Z","dateModified":"2021-10-07T14:17:10.317Z","description":"JWT Tokens are awesome but how do you store them securely in your front-end? We’ll go over the pros and cons of localStorage and Cookies. Local storage is...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/771df5cfdca400c7c29c3dd664bde5cd","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/771df5cfdca400c7c29c3dd664bde5cd","isAccessibleForFree":true,"articleSection":"codeburst","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"codeburst","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/codeburst","url":"https://daily.dev/sources/codeburst"},"commentCount":1,"discussionUrl":"https://daily.dev/posts/localstorage-vs-cookies-all-you-need-to-know-about-storing-jwt-tokens-securely-in-the-front-end-psqy2fkel","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":27},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":"webdev,security,javascript,cyber,authentication","timeRequired":"PT5M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"codeburst","item":"https://daily.dev/sources/codeburst"},{"@type":"ListItem","position":3,"name":"LocalStorage vs. Cookies: All You Need to Know About Storing JWT Tokens Securely in the Front-End"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/localstorage-vs-cookies-all-you-need-to-know-about-storing-jwt-tokens-securely-in-the-front-end-psqy2fkel","comment":[{"@type":"Comment","text":"I encourage you to read the article but the rule of thumb is to save access token in memory and refresh token in a cookie","datePublished":"2020-09-16T05:59:05.839Z","url":"https://daily.dev/posts/PSqY2FkEL#c-_41C7K6_c","author":{"@type":"Person","name":"Ido Shamun","url":"https://daily.dev/idoshamun","image":"https://media.daily.dev/image/upload/s---xy_OAwk--/f_auto,q_auto/v1703781380/avatars/avatar_28849d86070e4c099c877ab6837c61f0"}}]}
```

