---
title: "Add Daily Streak Feature & Boost Retention [Developer's Guide]"
entityName: "EnactOn Technologies Private Limited"
pageType: "Article"
url: "https://www.enacton.com/blog/daily-streak-feature/"
rawMdUrl: "https://www.enacton.com/blog/daily-streak-feature.md"
lastUpdated: "2024-10-14"
---

# Add Daily Streak Feature & Boost Retention [Developer's Guide]

## Additional Documentation & Details

What keeps users hooked to an app, coming back day after day?

It’s not just great content or design; it's the thrill of progress and rewards. Imagine opening an app daily, watching your streak grow, and earning bigger rewards as you hit new milestones.

It’s addictive, motivating, and incredibly powerful for boosting user engagement. In fact, this feature worked really well and helped [Duolingo](https://www.duolingo.com/) get over [17 million DAUs](https://sensortower.com/blog/duolingo-streak-feature-app-engagement-growth) for their platform.

In this article, we'll explore how you can build your very own daily rewards streak system—one that transforms casual users into loyal, daily visitors.

From understanding the psychology behind streaks and rewards to crafting a flexible, user-friendly experience, we’ll guide you through every step of development.

**What is a Daily Streak?**

A daily streak refers to a feature in applications that tracks how many consecutive days a user engages with the app. Every time a user completes a predefined action (such as logging in or completing a task) daily, their streak increases by one. However, if the user misses a day, the streak resets to zero.

### **Why Implement Daily Streak Feature?**

Daily streaks are an effective way to boost user engagement. They encourage users to return to your platform consistently by offering rewards or incentives tied to maintaining the streak. Some key benefits of implementing the daily streak feature include:

- **Increased User Retention**: Users are more likely to return to your app to maintain their streak.

- **Boosted User Motivation**: The visual progress of a streak creates a sense of accomplishment.

- **Gamification**: Streaks add a fun, competitive element, especially when combined with rewards.

## How Different Industries Can Use Daily Streak Rewards Feature?

- **Fitness and Health Apps**: Fitness apps could encourage users to log their workouts or meals daily. As a reward, users might get things like badges, discount coupons for fitness gear, or even a free month of premium features after hitting a certain number of consecutive days.

- **Educational Platforms**: To keep students motivated, educational platforms could reward them for completing daily lessons or quizzes. Rewards could be things like bonus content, points towards discounts on courses, or even digital certificates.

- **Banking and Finance**: Banks could get customers to use their apps daily by offering points for checking financial statuses or tracking daily spending. These points could then be used for perks like reduced service fees or better rates on savings accounts.

- **E-Commerce**: Online stores could encourage shoppers to log in every day by giving them access to exclusive flash sales or points that can be redeemed for discounts on future purchases.

- **Streaming Services**: These services could keep viewers coming back daily by rewarding them with access to exclusive content or periods of ad-free streaming after they log in several days in a row.

- **Mobile and Video Games**: Games can keep players engaged by offering daily rewards like in-game currency, special items, or early access to new content just for logging in.

- **Online Publishing**: Publishers could drive daily traffic by giving readers access to premium articles after a certain number of visits, or discounts on subscriptions

## How to Create a Daily Streak Rewards for Your Platform?

### **Logic for daily streak rewards**

- **Start Streak**: When a user first engages, start tracking the streak from "Day 1."

- **Daily Check**: Every day, check if the user has logged in. If yes, increment the streak by 1. If they missed a day, reset the streak to "Day 1."

- **No Backtracking**: Users cannot undo their progress; the streak can only move forward or reset.

- **Complete and Reset**: Once a user completes a streak (e.g., 7 or 10 days), they receive a reward, and the streak resets to "Day 1."

- **Maintain Consistency**: The logic is designed to encourage daily activity, preventing users from skipping days or going back once the streak is started.

### **Step-by-Step Implementation for developing daily streak rewards feature**

#### **1\. Setting up User Streak Data**

The first step is to create a model or data structure to hold the streak-related information for a user. This will include:

- streakCount: The current streak the user has.

- lastActive: The last date the user interacted with the app.

- maxStreak: The maximum number of days needed to complete the streak.

Here’s an example of how this data might look:

<style>
.enacton-code-wrap {
  width: calc(100% - 32px);
  max-width: 850px;
  margin: 28px auto;
}
.enacton-code-box {
  background: #1e1e1e;
  border: 1px solid #2f2f2f;
  border-radius: 8px;
  overflow-x: auto;
  padding: 16px 0;
  
  font-size: 14px;
  line-height: 24px;
}
.enacton-code-line {
  display: flex;
  min-width: max-content;
}
.enacton-line-number {
  width: 46px;
  flex-shrink: 0;
  text-align: right;
  padding-right: 14px;
  margin-right: 14px;
  color: #858585;
  user-select: none;
}
.enacton-code-text {
  padding-right: 20px;
  white-space: pre;
  color: #d4d4d4;
}
.code-keyword {
  color: #569cd6;
}
.code-variable,
.code-property {
  color: #9cdcfe;
}
.code-number {
  color: #b5cea8;
}
.code-null {
  color: #569cd6;
}
.code-comment {
  color: #6a9955;
}
@media (max-width: 768px) {
  .enacton-code-wrap {
    width: 100%;
    margin: 22px auto;
  }
  .enacton-code-box {
    font-size: 13px;
    line-height: 22px;
  }
  .enacton-line-number {
    width: 38px;
    padding-right: 10px;
    margin-right: 10px;
  }
}
</style>
<div class="enacton-code-wrap">
  <div class="enacton-code-box">
    <div class="enacton-code-line">
      <span class="enacton-line-number">1</span>
      <span class="enacton-code-text"><span class="code-keyword">const</span> <span class="code-variable">user</span> = {</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">2</span>
      <span class="enacton-code-text">  <span class="code-property">streakCount</span>: <span class="code-number">0</span>,      <span class="code-comment">// Current streak count (number of consecutive active days)</span></span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">3</span>
      <span class="enacton-code-text">  <span class="code-property">lastActive</span>: <span class="code-null">null</span>,    <span class="code-comment">// Date of the user's last activity (e.g., '2024-10-13')</span></span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">4</span>
      <span class="enacton-code-text">  <span class="code-property">maxStreak</span>: <span class="code-number">7</span>,        <span class="code-comment">// Maximum number of days for the streak (can be configured as needed)</span></span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">5</span>
      <span class="enacton-code-text">};</span>
    </div>
  </div>
</div>

**Explanation:**

- We initialize a user object that holds the necessary streak-related information.

#### **2\. Time Management Logic**

To track daily streaks, you need to compare the current date with the user’s last active date. The streak should only increment if the user logs in on the next consecutive day. If they miss a day, the streak resets.

Here’s how you could handle this:

<style>
.enacton-code-wrap {
  width: calc(100% - 32px);
  max-width: 850px;
  margin: 28px auto;
}
.enacton-code-box {
  background: #1e1e1e;
  border: 1px solid #2f2f2f;
  border-radius: 8px;
  overflow-x: auto;
  padding: 16px 0;
  
  font-size: 14px;
  line-height: 24px;
}
.enacton-code-line {
  display: flex;
  min-width: max-content;
}
.enacton-line-number {
  width: 46px;
  flex-shrink: 0;
  text-align: right;
  padding-right: 14px;
  margin-right: 14px;
  color: #858585;
  user-select: none;
}
.enacton-code-text {
  padding-right: 20px;
  white-space: pre;
  color: #d4d4d4;
}
.code-keyword {
  color: #569cd6;
}
.code-variable,
.code-property {
  color: #9cdcfe;
}
.code-number {
  color: #b5cea8;
}
.code-comment {
  color: #6a9955;
}
.code-function {
  color: #dcdcaa;
}
@media (max-width: 768px) {
  .enacton-code-wrap {
    width: 100%;
    margin: 22px auto;
  }
  .enacton-code-box {
    font-size: 13px;
    line-height: 22px;
  }
  .enacton-line-number {
    width: 38px;
    padding-right: 10px;
    margin-right: 10px;
  }
}
</style>
<div class="enacton-code-wrap">
  <div class="enacton-code-box">
    <div class="enacton-code-line">
      <span class="enacton-line-number">1</span>
      <span class="enacton-code-text"><span class="code-keyword">function</span> <span class="code-function">checkStreak</span>(user) {</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">2</span>
      <span class="enacton-code-text">  <span class="code-keyword">const</span> <span class="code-variable">currentDate</span> = <span class="code-keyword">new</span> <span class="code-function">Date</span>(); <span class="code-comment">// Get the current date</span></span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">3</span>
      <span class="enacton-code-text"></span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">4</span>
      <span class="enacton-code-text">  <span class="code-keyword">if</span> (!user.lastActive) {</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">5</span>
      <span class="enacton-code-text">    <span class="code-comment">// First interaction, initialize the lastActive date and start the streak</span></span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">6</span>
      <span class="enacton-code-text">    user.lastActive = currentDate;</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">7</span>
      <span class="enacton-code-text">    user.streakCount = <span class="code-number">1</span>;</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">8</span>
      <span class="enacton-code-text">  } <span class="code-keyword">else</span> {</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">9</span>
      <span class="enacton-code-text">    <span class="code-keyword">const</span> <span class="code-variable">lastActiveDate</span> = <span class="code-keyword">new</span> <span class="code-function">Date</span>(user.lastActive); <span class="code-comment">// Convert lastActive to Date object</span></span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">10</span>
      <span class="enacton-code-text"></span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">11</span>
      <span class="enacton-code-text">    <span class="code-comment">// Calculate the difference in days between current date and last active date</span></span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">12</span>
      <span class="enacton-code-text">    <span class="code-keyword">const</span> <span class="code-variable">differenceInDays</span> = Math.<span class="code-function">floor</span>(</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">13</span>
      <span class="enacton-code-text">      (currentDate - lastActiveDate) / (<span class="code-number">1000</span> * <span class="code-number">60</span> * <span class="code-number">60</span> * <span class="code-number">24</span>)</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">14</span>
      <span class="enacton-code-text">    );</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">15</span>
      <span class="enacton-code-text"></span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">16</span>
      <span class="enacton-code-text">    <span class="code-keyword">if</span> (differenceInDays === <span class="code-number">1</span>) {</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">17</span>
      <span class="enacton-code-text">      <span class="code-comment">// User logged in the next day, increment the streak</span></span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">18</span>
      <span class="enacton-code-text">      user.streakCount += <span class="code-number">1</span>;</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">19</span>
      <span class="enacton-code-text">    } <span class="code-keyword">else if</span> (differenceInDays &gt; <span class="code-number">1</span>) {</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">20</span>
      <span class="enacton-code-text">      <span class="code-comment">// User missed one or more days, reset the streak</span></span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">21</span>
      <span class="enacton-code-text">      user.streakCount = <span class="code-number">1</span>;</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">22</span>
      <span class="enacton-code-text">    }</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">23</span>
      <span class="enacton-code-text">  }</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">24</span>
      <span class="enacton-code-text"></span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">25</span>
      <span class="enacton-code-text">  <span class="code-comment">// Update last active date to the current date</span></span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">26</span>
      <span class="enacton-code-text">  user.lastActive = currentDate;</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">27</span>
      <span class="enacton-code-text">}</span>
    </div>
  </div>
</div>

**Explanation:**

- currentDate: Gets the current date when the function is called.

- The function checks if lastActive is null (i.e., it's the first time the user is logging in):

- If lastActive is already set:

- Finally, lastActive is updated to the current date.

#### **3\. Streak Progression and Reset**

Now, we need logic to handle streak completion and reset. For example, if the streak reaches the maximum configured streak, we can reward the user and reset the streak.

<style>
.enacton-code-wrap {
  width: calc(100% - 32px);
  max-width: 850px;
  margin: 28px auto;
}
.enacton-code-box {
  background: #1e1e1e;
  border: 1px solid #2f2f2f;
  border-radius: 8px;
  overflow-x: auto;
  padding: 16px 0;
  
  font-size: 14px;
  line-height: 24px;
}
.enacton-code-line {
  display: flex;
  min-width: max-content;
}
.enacton-line-number {
  width: 46px;
  flex-shrink: 0;
  text-align: right;
  padding-right: 14px;
  margin-right: 14px;
  color: #858585;
  user-select: none;
}
.enacton-code-text {
  padding-right: 20px;
  white-space: pre;
  color: #d4d4d4;
}
.code-keyword {
  color: #569cd6;
}
.code-variable,
.code-property {
  color: #9cdcfe;
}
.code-number {
  color: #b5cea8;
}
.code-comment {
  color: #6a9955;
}
.code-function {
  color: #dcdcaa;
}
.code-string {
  color: #ce9178;
}
@media (max-width: 768px) {
  .enacton-code-wrap {
    width: 100%;
    margin: 22px auto;
  }
  .enacton-code-box {
    font-size: 13px;
    line-height: 22px;
  }
  .enacton-line-number {
    width: 38px;
    padding-right: 10px;
    margin-right: 10px;
  }
}
</style>
<div class="enacton-code-wrap">
  <div class="enacton-code-box">
    <div class="enacton-code-line">
      <span class="enacton-line-number">1</span>
      <span class="enacton-code-text"><span class="code-keyword">function</span> <span class="code-function">handleStreakProgress</span>(user) {</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">2</span>
      <span class="enacton-code-text">  <span class="code-comment">// Check and update the user's streak</span></span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">3</span>
      <span class="enacton-code-text">  <span class="code-function">checkStreak</span>(user);</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">4</span>
      <span class="enacton-code-text"></span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">5</span>
      <span class="enacton-code-text">  <span class="code-comment">// If the streak count reaches the maximum streak value</span></span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">6</span>
      <span class="enacton-code-text">  <span class="code-keyword">if</span> (user.streakCount === user.maxStreak) {</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">7</span>
      <span class="enacton-code-text">    console.<span class="code-function">log</span>(<span class="code-string">'Congrats! You completed your streak. Enjoy your reward!'</span>);</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">8</span>
      <span class="enacton-code-text"></span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">9</span>
      <span class="enacton-code-text">    <span class="code-comment">// Reset the streak after completion</span></span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">10</span>
      <span class="enacton-code-text">    user.streakCount = <span class="code-number">0</span>;</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">11</span>
      <span class="enacton-code-text">  }</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">12</span>
      <span class="enacton-code-text">}</span>
    </div>
  </div>
</div>

**Explanation:**

- handleStreakProgress(user): This function is called to manage the user’s streak.

- checkStreak(user): It first checks and updates the streak based on the user's activity.

- If streakCount equals maxStreak, it means the user has completed their streak. A message is displayed congratulating the user, and the streak is reset to 0 to start over.

#### **4\. Making the Streak Configurable**

If you want to make the streak duration configurable (for example, 7, 10, or 15 days), you can set this up dynamically:

<style>
.enacton-code-wrap {
  width: calc(100% - 32px);
  max-width: 850px;
  margin: 28px auto;
}
.enacton-code-box {
  background: #1e1e1e;
  border: 1px solid #2f2f2f;
  border-radius: 8px;
  overflow-x: auto;
  padding: 16px 0;
  
  font-size: 14px;
  line-height: 24px;
}
.enacton-code-line {
  display: flex;
  min-width: max-content;
}
.enacton-line-number {
  width: 46px;
  flex-shrink: 0;
  text-align: right;
  padding-right: 14px;
  margin-right: 14px;
  color: #858585;
  user-select: none;
}
.enacton-code-text {
  padding-right: 20px;
  white-space: pre;
  color: #d4d4d4;
}
.code-keyword {
  color: #569cd6;
}
.code-variable,
.code-property {
  color: #9cdcfe;
}
.code-number {
  color: #b5cea8;
}
.code-comment {
  color: #6a9955;
}
.code-function {
  color: #dcdcaa;
}
@media (max-width: 768px) {
  .enacton-code-wrap {
    width: 100%;
    margin: 22px auto;
  }
  .enacton-code-box {
    font-size: 13px;
    line-height: 22px;
  }
  .enacton-line-number {
    width: 38px;
    padding-right: 10px;
    margin-right: 10px;
  }
}
</style>
<div class="enacton-code-wrap">
  <div class="enacton-code-box">
    <div class="enacton-code-line">
      <span class="enacton-line-number">1</span>
      <span class="enacton-code-text"><span class="code-keyword">function</span> <span class="code-function">setMaxStreak</span>(user, maxDays) {</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">2</span>
      <span class="enacton-code-text">  <span class="code-comment">// Set the maximum streak for the user</span></span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">3</span>
      <span class="enacton-code-text">  user.<span class="code-property">maxStreak</span> = maxDays;</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">4</span>
      <span class="enacton-code-text">}</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">5</span>
      <span class="enacton-code-text"></span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">6</span>
      <span class="enacton-code-text"><span class="code-comment">// Example usage: Set the maximum streak to 10 days</span></span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">7</span>
      <span class="enacton-code-text"><span class="code-function">setMaxStreak</span>(user, <span class="code-number">10</span>);</span>
    </div>
  </div>
</div>

**Explanation:**

- setMaxStreak(user, maxDays): A utility function to set the maximum number of days required to complete a streak. This allows you to configure the streak duration easily.

- user.maxStreak = maxDays: Updates the user object with the desired maxDays value.

- setMaxStreak(user, 10): Sets the streak requirement to 10 days for this particular user.

#### **5\. Ensuring Users Can’t Claim Until Streak Completion**

To prevent users from claiming rewards until the streak is completed, we can add a condition to check if the user’s streak is incomplete:

<style>
.enacton-code-wrap {
  width: calc(100% - 32px);
  max-width: 850px;
  margin: 28px auto;
}
.enacton-code-box {
  background: #1e1e1e;
  border: 1px solid #2f2f2f;
  border-radius: 8px;
  overflow-x: auto;
  padding: 16px 0;
  
  font-size: 14px;
  line-height: 24px;
}
.enacton-code-line {
  display: flex;
  min-width: max-content;
}
.enacton-line-number {
  width: 46px;
  flex-shrink: 0;
  text-align: right;
  padding-right: 14px;
  margin-right: 14px;
  color: #858585;
  user-select: none;
}
.enacton-code-text {
  padding-right: 20px;
  white-space: pre;
  color: #d4d4d4;
}
.code-keyword {
  color: #569cd6;
}
.code-variable,
.code-property {
  color: #9cdcfe;
}
.code-number {
  color: #b5cea8;
}
.code-comment {
  color: #6a9955;
}
.code-function {
  color: #dcdcaa;
}
.code-string {
  color: #ce9178;
}
@media (max-width: 768px) {
  .enacton-code-wrap {
    width: 100%;
    margin: 22px auto;
  }
  .enacton-code-box {
    font-size: 13px;
    line-height: 22px;
  }
  .enacton-line-number {
    width: 38px;
    padding-right: 10px;
    margin-right: 10px;
  }
}
</style>
<div class="enacton-code-wrap">
  <div class="enacton-code-box">
    <div class="enacton-code-line">
      <span class="enacton-line-number">1</span>
      <span class="enacton-code-text"><span class="code-keyword">function</span> <span class="code-function">canClaimReward</span>(user) {</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">2</span>
      <span class="enacton-code-text">  <span class="code-comment">// Check if the user can claim the reward by comparing streakCount with maxStreak</span></span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">3</span>
      <span class="enacton-code-text">  <span class="code-keyword">return</span> user.<span class="code-property">streakCount</span> === user.<span class="code-property">maxStreak</span>;</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">4</span>
      <span class="enacton-code-text">}</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">5</span>
      <span class="enacton-code-text"></span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">6</span>
      <span class="enacton-code-text"><span class="code-comment">// Example usage</span></span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">7</span>
      <span class="enacton-code-text"><span class="code-keyword">if</span> (<span class="code-function">canClaimReward</span>(user)) {</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">8</span>
      <span class="enacton-code-text">  console.<span class="code-function">log</span>(<span class="code-string">'You can claim your reward!'</span>);</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">9</span>
      <span class="enacton-code-text">} <span class="code-keyword">else</span> {</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">10</span>
      <span class="enacton-code-text">  console.<span class="code-function">log</span>(<span class="code-string">`You need to maintain your streak for ${user.maxStreak - user.streakCount} more days.`</span>);</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">11</span>
      <span class="enacton-code-text">}</span>
    </div>
  </div>
</div>

**Explanation:**

- canClaimReward(user): This function checks if the user has met the streak completion criteria.

- **Conditional Check**:

#### **6\. Resetting the Streak**

Once a user completes a streak, their streak resets to zero, and the process starts again from day 1.

<style>
.enacton-code-wrap {
  width: calc(100% - 32px);
  max-width: 850px;
  margin: 28px auto;
}
.enacton-code-box {
  background: #1e1e1e;
  border: 1px solid #2f2f2f;
  border-radius: 8px;
  overflow-x: auto;
  padding: 16px 0;
  
  font-size: 14px;
  line-height: 24px;
}
.enacton-code-line {
  display: flex;
  min-width: max-content;
}
.enacton-line-number {
  width: 46px;
  flex-shrink: 0;
  text-align: right;
  padding-right: 14px;
  margin-right: 14px;
  color: #858585;
  user-select: none;
}
.enacton-code-text {
  padding-right: 20px;
  white-space: pre;
  color: #d4d4d4;
}
.code-keyword {
  color: #569cd6;
}
.code-property {
  color: #9cdcfe;
}
.code-number {
  color: #b5cea8;
}
.code-comment {
  color: #6a9955;
}
.code-function {
  color: #dcdcaa;
}
.code-string {
  color: #ce9178;
}
@media (max-width: 768px) {
  .enacton-code-wrap {
    width: 100%;
    margin: 22px auto;
  }
  .enacton-code-box {
    font-size: 13px;
    line-height: 22px;
  }
  .enacton-line-number {
    width: 38px;
    padding-right: 10px;
    margin-right: 10px;
  }
}
</style>
<div class="enacton-code-wrap">
  <div class="enacton-code-box">
    <div class="enacton-code-line">
      <span class="enacton-line-number">1</span>
      <span class="enacton-code-text"><span class="code-keyword">function</span> <span class="code-function">resetStreak</span>(user) {</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">2</span>
      <span class="enacton-code-text">  <span class="code-comment">// Check if the user has completed the streak</span></span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">3</span>
      <span class="enacton-code-text">  <span class="code-keyword">if</span> (user.<span class="code-property">streakCount</span> === user.<span class="code-property">maxStreak</span>) {</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">4</span>
      <span class="enacton-code-text">    <span class="code-comment">// Reset the streak count after completion</span></span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">5</span>
      <span class="enacton-code-text">    user.<span class="code-property">streakCount</span> = <span class="code-number">0</span>;</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">6</span>
      <span class="enacton-code-text">    console.<span class="code-function">log</span>(<span class="code-string">'Streak reset. Start from day 1 again!'</span>);</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">7</span>
      <span class="enacton-code-text">  }</span>
    </div>
    <div class="enacton-code-line">
      <span class="enacton-line-number">8</span>
      <span class="enacton-code-text">}</span>
    </div>
  </div>
</div>

**Explanation:**

- resetStreak(user): A function to reset the user's streak after completion.

### **Additional Considerations**

- **Tracking Daily Logins**: You can choose to track user activity through logins, specific actions like completing tasks, or even page visits.

- **Handling Time Zones**: Make sure to handle time zone differences if you have a global user base. Use the user's local time zone to calculate streaks correctly.

- **User Notifications**: You can notify users about streak status using in-app messages or emails. Notify them when they’re close to completing the streak or when they’ve missed a day.

Also read: _[How to Develop Daily Bonus Ladder Feature](/blog/develop-daily-bonus-ladder-feature/)_

### **Conclusion**

Implementing a daily streak feature can have a tremendous impact on user engagement and retention in your application. By using simple JavaScript logic, you can configure streak lengths, handle streak progression, and reward users for maintaining their streaks.

With the flexibility to adjust streak durations and define rewards for streak completions, this feature offers a powerful gamification element to keep users motivated and engaged with your application.

Feel free to modify the code snippets provided to suit your platform's architecture.

---
## Company Entity & Canonical Verification
- **Legal Business Name:** EnactOn Technologies Private Limited
- **Headquarters:** 605, Luxuria Business Hub, Nr. V R Mall, Vesu, Surat, Gujarat, INDIA – 395007
- **Official Website:** https://www.enacton.com
- **Direct Contact:** contact@enacton.com | +91 74260 60610
- **Career Enquiries:** careers@enacton.com | (+91) 90790 45453
- **Primary Service Category:** Custom Software Development, Startup MVP Engineering, White-Label Platform Development & IT Consulting
