<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ziya Fenn on Medium]]></title>
        <description><![CDATA[Stories by Ziya Fenn on Medium]]></description>
        <link>https://medium.com/@ziyafenn?source=rss-e04adf5bbc45------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*mP588fxHmSm7k3VZISBJCA.jpeg</url>
            <title>Stories by Ziya Fenn on Medium</title>
            <link>https://medium.com/@ziyafenn?source=rss-e04adf5bbc45------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 15:05:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ziyafenn/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Password protect page in Next.js]]></title>
            <link>https://medium.com/@ziyafenn/password-protect-page-in-nextjs-5820cd7078ae?source=rss-e04adf5bbc45------2</link>
            <guid isPermaLink="false">https://medium.com/p/5820cd7078ae</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Ziya Fenn]]></dc:creator>
            <pubDate>Tue, 10 Oct 2023 19:47:18 GMT</pubDate>
            <atom:updated>2023-10-12T14:31:21.470Z</atom:updated>
            <content:encoded><![CDATA[<p>Whether you’re showcasing your portfolio or your website is handling sensitive information, implementing password protection for your web pages might be required. In this article, we’ll delve into the process of adding password protection to pages generated with Next.js 13.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BeLTpdIVidhz2uRXoYI3Uw.jpeg" /></figure><h3>What We Aim to Achieve</h3><ul><li>When a user navigates to a protected page, we will present a modal dialog that prompts them to enter a password.</li><li>After entering the correct password, the dialog will disappear, allowing the content to load, and the password will be securely stored in the user’s cache.</li><li>This cached password will enable users to bypass the password protection on subsequent visits.</li><li>Additionally, we will provide a method for skipping password entry by incorporating a query parameter into the URL, sparing users from manual password input.</li></ul><h3>Setting Up Environment Variables</h3><p>Let’s move forward by creating the <strong><em>.env.local</em></strong> file in the root folder of your Next.js project and defining the necessary variables within it. These variables will serve as the keys to ensuring that only authorized users can access your protected content.</p><pre>PASSWORD_COOKIE_NAME=hasAccess // key for a cookie to check if user is authenticated<br>SEARCH_QUERY_NAME=password // key for url query to check if url contains password<br>PAGE_PASSWORD=PasswordForWebsite // actual page password</pre><h3>Creating the Password Prompt Modal</h3><p>In this section, we’ll design a password prompt modal that incorporates a password field, allowing users to authenticate. Once the user submits the form within this modal, we’ll proceed to send a <strong>POST</strong> request to a designated API route, a topic we’ll explore in the next step.</p><pre>// components/PasswordPromptDialog.tsx<br>&quot;use client&quot;;<br><br>import React, { useState } from &#39;react&#39;;<br><br>const PasswordPromptDialog = ({ onSubmit }) =&gt; {<br> const [password, setPassword] = useState(&#39;&#39;);<br> const [passwordIncorrect, setPasswordIncorrect] = useState(false)<br> const [loading, setLoading] = useState(false);<br><br>const handleSubmit = (e) =&gt; {<br> const onSubmit = async (e: React.FormEvent) =&gt; {<br> e.preventDefault();<br> setLoading(true);<br> const request = await fetch(`/api`, {<br> body: JSON.stringify({password}),<br> headers: {&quot;Content-Type&quot;: &quot;application/json&quot;},<br> method: &quot;post&quot;,<br> });<br><br>if (request.status !== 200) <br> return setPasswordIncorrect(true), setLoading(false);<br>else window.location.reload();<br>};<br><br>return (<br> &lt;div className=”password-prompt-dialog”&gt;<br>   &lt;form onSubmit={handleSubmit}&gt;<br>     &lt;label htmlFor=”password”&gt;Password:&lt;/label&gt;<br>     &lt;input<br>     type=”password”<br>     id=”password”<br>     value={password}<br>     onChange={(e) =&gt; setPassword(e.target.value)}<br>     /&gt;<br>     &lt;button type=”submit”&gt;Submit&lt;/button&gt;<br>   &lt;/form&gt;<br>   &lt;/div&gt;<br> );<br>};<br><br>export default PasswordPromptDialog;</pre><h3>Handling the POST Request</h3><p>Next, we need to handle the POST request to the API route when the user submits the form. We’ll create a route in a dedicated folder under the Next.js <strong><em>api</em></strong> directory.</p><h4>Creating the API Route</h4><p>Under <strong><em>api</em></strong> folder, create a new file named <strong><em>route.ts</em></strong> that handles the <strong>POST</strong> request:</p><pre>// api/route.ts<br>import { serialize } from &quot;cookie&quot;;<br><br>export async function POST(request: Request, params: { slug: string }) {<br> const data: { password: string } = await request.json();<br> const password = data.password;<br> const cookie = serialize(process.env.PASSWORD_COOKIE_NAME!, “true”, <br> {<br> httpOnly: true,<br> path: “/”,<br> });<br><br>if (process.env.PAGE_PASSWORD !== password) {<br> return new Response(&quot;incorrect password&quot;, {<br> status: 401,<br> });<br> }<br><br>return new Response(&quot;password correct&quot;, {<br> status: 200,<br> headers: {<br> &quot;Set-Cookie&quot;: cookie,<br> },<br> });<br>}</pre><p>When the user enters the correct password we send a response and set cookies using an environment variable as a key for the cookie.</p><blockquote>For adding cookie data, i utilize the <a href="https://www.npmjs.com/package/cookie">cookie library</a>, which simplifies serialization of the data.</blockquote><h3>Creating a password protected page</h3><p>We leverage cookies to determine whether a user is authenticated or not. In cases where authentication is required, we display the previously created<strong> &lt;PasswordPromptDialog /&gt;</strong>. Otherwise, when a user is authenticated, we proceed to load and render the page content.</p><pre><br>// app/page.tsx<br>const Page = (props) =&gt; {<br> const cookiesStore = cookies();<br> const loginCookies cookiesStore.get(process.env.PASSWORD_COOKIE_NAME!);<br> const isLoggedIn = !!loginCookies?.value;<br> <br> if (!isLoggedIn) {<br>   return &lt;PasswordPromptDialog /&gt;;<br> } else {<br> // User is authenticated, load data and render content<br> // …<br> }<br>}<br></pre><p>In this example, we are utilising <a href="https://nextjs.org/docs/app/api-reference/functions/cookies">cookies function of Next.js</a> to read the cookies that were set in <strong>&lt;PasswordPromptDialog /&gt;</strong> component.</p><h3>Skipping manual password entry with URL query</h3><p>Let’s take it one step further and allow users with whom we share our website url to access the protected page without the need for password.</p><p>To achieve this, we embed the password directly into the URL as a query parameter, eliminating the need for manual password input.</p><p>This automation is made possible through <a href="https://nextjs.org/docs/app/building-your-application/routing/middleware">Next.js middleware</a>:</p><pre>// middleware.ts<br>import { NextResponse } from &quot;next/server&quot;;<br>import type { NextRequest } from &quot;next/server&quot;;<br><br>export function middleware(request: NextRequest) {<br> const password = request.nextUrl.searchParams.get(<br> process.env.SEARCH_QUERY_NAME!<br> );<br> const hasCookie = request.cookies.has(process.env.PASSWORD_COOKIE_NAME!);<br> const url = request.nextUrl.clone();<br> const response = NextResponse.redirect(url);<br><br>if (password === process.env.PAGE_PASSWORD &amp;&amp; !hasCookie) {<br> response.cookies.set(`${process.env.PASSWORD_COOKIE_NAME}`, &quot;true&quot;);<br> return response;<br> }<br>}</pre><p>When sharing your website with users, simply use your URL with the query key you’ve configured in your environment variables. For example, <strong><em>example.com/protected?password=yourPassword</em></strong>. You can apply this query to any route within your URL, and it will function in the same way.</p><p>Hope this tutorial helps you to setup page password protection for your website.</p><p>Happy Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5820cd7078ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Design Systems in 2016 and how to make your own.]]></title>
            <link>https://uxplanet.org/design-systems-in-2016-5415a660b29?source=rss-e04adf5bbc45------2</link>
            <guid isPermaLink="false">https://medium.com/p/5415a660b29</guid>
            <category><![CDATA[design]]></category>
            <category><![CDATA[ux]]></category>
            <category><![CDATA[design-process]]></category>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[product-design]]></category>
            <dc:creator><![CDATA[Ziya Fenn]]></dc:creator>
            <pubDate>Sun, 18 Dec 2016 20:08:39 GMT</pubDate>
            <atom:updated>2017-10-14T11:04:16.976Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_MIiZDYNJs3fjiADOMkiAg.png" /><figcaption>Atomic Design by Brad Frost</figcaption></figure><p>2016 was a great year for UX. Many great articles were published and many exceptional thoughts were shared.</p><p>One of the important topics in UX was so called “Design Systems”.</p><p>I’d like to share with you a list of Design Systems and a recap of helpful articles to help you get started with creating your own Design System.</p><p><strong>A few great examples of Design Systems you should be aware of:</strong></p><p>Material Design</p><p><a href="https://material.io/">Material Design</a></p><p>iOS Human Interface Guidelines</p><p><a href="https://developer.apple.com/ios/human-interface-guidelines/overview/design-principles/">Themes - iOS - Human Interface Guidelines - Apple Developer</a></p><p>Microsoft Design</p><p><a href="https://www.microsoft.com/en-us/design/principles">Microsoft Design</a></p><p>IBM Design</p><p><a href="http://www.ibm.com/design/">IBM Design: design in motion</a></p><p>Airbnb design</p><p><a href="http://airbnb.design/building-a-visual-language/">Building a Visual Language</a></p><p>Clarity Design System</p><p><a href="https://vmware.github.io/clarity/">Clarity Design System</a></p><p>The Harmony Design System</p><p><a href="http://harmony.intuit.com/">QuickBooks Design System - Design success starts here</a></p><p>BBC GEL</p><p><a href="http://www.bbc.co.uk/gel">BBC GEL | Homepage</a></p><p>Lightning Design System</p><p><a href="https://www.lightningdesignsystem.com/">Lightning Design System 2</a></p><p>MailChimp</p><p><a href="http://ux.mailchimp.com/">Grid System | MailChimp</a></p><p>PEGA</p><p><a href="http://design.pega.com/">Pega UX Design System</a></p><p>LonelyPlanet</p><p><a href="http://rizzo.lonelyplanet.com/styleguide/design-elements/colours">Lonely Planet Travel Guides and Travel Information</a></p><p>GE’s Predix Design System</p><p><a href="https://medium.com/ge-design/ges-predix-design-system-8236d47b0891">GE’s Predix Design System</a></p><p>Oracle Alta</p><p><a href="http://www.oracle.com/webfolder/ux/middleware/alta/patterns/index.html">Oracle Alta UI Patterns: Introduction</a></p><p>U.S. Web Design Standards</p><p><a href="https://standards.usa.gov/">U.S. Web Design System: A design system for the federal government</a></p><p><strong>Here are a few articles and resources which will help you to get started with creating a Design System:</strong></p><p>Atomic Design</p><p><a href="http://atomicdesign.bradfrost.com/table-of-contents/">Atomic Design | Atomic Design by Brad Frost</a></p><p>Pattern Lab (Based on Atomic Design)</p><p><a href="http://patternlab.io/">Pattern Lab | Build Atomic Design Systems</a></p><p>How Creating A Design Language Can Streamline Your UX Design Process</p><p><a href="https://www.smashingmagazine.com/2016/12/how-creating-a-design-language-can-streamline-your-ux-design-process/">How Creating A Design Language Can Streamline Your UX Design Process</a></p><p>Creating a Design System Language</p><p><a href="https://medium.com/globoforce-design/creating-a-design-system-158a2d832551">Creating a Design System Language…</a></p><p>Promoting a Design System Across Your Products</p><p><a href="http://alistapart.com/article/promoting-a-design-system-across-your-products">Promoting a Design System Across Your Products</a></p><p><strong>Some practical tips:</strong></p><p>How to create a FRONT END FRAMEWORK with Sketch</p><p><a href="https://medium.com/sketch-app-sources/how-to-create-a-front-end-framework-with-sketch-2379edb5e7df">How to create a FRONT END FRAMEWORK with Sketch</a></p><p>How To Be More Organized While Designing UI</p><p><a href="https://medium.com/sketch-app-sources/how-to-be-more-organized-while-designing-ui-90d2d69cfb4f">How To Be More Organized While Designing UI</a></p><p>Intro to the 8-Point Grid System</p><p><a href="https://medium.com/built-to-adapt/intro-to-the-8-point-grid-system-d2573cde8632">Intro to the 8-Point Grid System</a></p><p>5 Things to Do Before You Start Your Next Design File in Sketch</p><p><a href="https://medium.com/ux-power-tools/5-things-to-do-before-you-start-your-next-design-file-in-sketch-or-preparing-your-design-mise-en-ff7ea9fe3722">5 Things to Do Before You Start Your Next Design File in Sketch, or, Preparing Your Design “mise en…</a></p><p>Super easy Atomic Design documentation with Sketch app</p><p><a href="https://nordnet.design/super-easy-atomic-design-documentation-with-sketch-app-c5eb9df0f6fa">Super easy Atomic Design documentation with Sketch app</a></p><p><strong>And a few more links to read more about Design Systems:</strong></p><p>Researching Design Systems</p><p><a href="http://danielmall.com/articles/researching-design-systems/">Researching Design Systems</a></p><p>Styleguides + Design Languages</p><p><a href="https://medium.com/hh-design/styleguides-design-languages-36b9e6449e60">Styleguides + Design Languages</a></p><p>All about creating design style guides</p><p><a href="https://medium.mybridge.co/all-about-creating-design-style-guides-cba6f6ca509d">All about creating design style guides</a></p><p>UXPin Step-by-Step Guide for creating a Design System</p><p><a href="https://www.uxpin.com/create-design-system-guide">Design Systems: Step-by-Step Guide to Creating Your Own</a></p><p>Hope you enjoyed the article! If so, please don’t forget to like it ;)</p><p>If you have any resource that would fit this list i will be happy to update it.</p><p><em>Follow me on </em><a href="http://dribbble.com/ziyafenn"><em>Dribbble</em></a><em> and </em><a href="http://behance.net/ziyafenn"><em>Behance</em></a><em>.</em></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fb3e808%3Fas_embed%3Dtrue&amp;dntp=1&amp;display_name=Upscribe&amp;url=https%3A%2F%2Fupscri.be%2Fb3e808%2F&amp;image=http%3A%2F%2Fapi.screenshotlayer.com%2Fapi%2Fcapture%3Faccess_key%3Dfe59908dad3baab69ffab249a2224b03%26viewport%3D1024x612%26width%3D1000%26url%3Dhttps%253A%252F%252Fupscri.be%252Fb3e808%253Fscreenshot&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/96d08ab34921bdd17986cb5c0396842f/href">https://medium.com/media/96d08ab34921bdd17986cb5c0396842f/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5415a660b29" width="1" height="1" alt=""><hr><p><a href="https://uxplanet.org/design-systems-in-2016-5415a660b29">Design Systems in 2016 and how to make your own.</a> was originally published in <a href="https://uxplanet.org/">UX Planet</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>