# Adding months navigation

Now that we have our calendar, we need to allow the user to navigate through months and years.\
We do that by using the `nextMonth`, `previousMonth`, `nextYear` & `previousYear` functions.

<pre class="language-tsx" data-title="MyFirstCalendar.tsx" data-full-width="false"><code class="lang-tsx">import useCalendar from "../useCalendar";
import "./style.css";

const MyFirstCalendar = () => {
  const {
    displayedMonths,
    register,
<strong>+ nextMonth,   
</strong><strong>+ nextYear,   
</strong><strong>+ previousMonth,   
</strong><strong>+ previousYear,   
</strong>  } = useCalendar();

  return (
    &#x3C;div>
      &#x3C;h1>My first calendar&#x3C;/h1>
      {displayedMonths.map((month) => {
        return (
          &#x3C;div key={month.name}>
            &#x3C;div className="monthHeader">
              &#x3C;button onClick={() => previousYear()}>{"&#x3C;&#x3C;&#x3C;"}&#x3C;/button>
              &#x3C;button onClick={() => previousMonth()}>{"&#x3C;&#x3C;"}&#x3C;/button>
              &#x3C;h2>
                {month.name} {month.year}
              &#x3C;/h2>
              &#x3C;button onClick={() => nextMonth()}>{">>"}&#x3C;/button>
              &#x3C;button onClick={() => nextYear()}>{">>>"}&#x3C;/button>
            &#x3C;/div>
            &#x3C;div className="daysGrid">
              {month.days.map((day) => {
                return &#x3C;div {...register(month, day)}>{day.number}&#x3C;/div>;
              })}
            &#x3C;/div>
          &#x3C;/div>
        );
      })}
    &#x3C;/div>
  );
};

export default MyFirstCalendar;

</code></pre>

Now you can navigate through the months and years of your calendar :white\_check\_mark:&#x20;

<figure><img src="https://84498366-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F20lkp7X7epsxYdQjhHGn%2Fuploads%2F7AaJcQVUp6Onc0iyBXmg%2Fimage.png?alt=media&#x26;token=1250fa7f-7641-4283-a8ff-4133e5bddc91" alt=""><figcaption></figcaption></figure>
