<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Szymon Kabelis</title>
    <description>The latest articles on DEV Community by Szymon Kabelis (@szymkab).</description>
    <link>https://dev.to/szymkab</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F111678%2Fec9c85bc-a9a7-4785-99a5-bebb14bff1a0.png</url>
      <title>DEV Community: Szymon Kabelis</title>
      <link>https://dev.to/szymkab</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/szymkab"/>
    <language>en</language>
    <item>
      <title>Next.js authentication with existing backend</title>
      <dc:creator>Szymon Kabelis</dc:creator>
      <pubDate>Wed, 31 Mar 2021 09:03:00 +0000</pubDate>
      <link>https://dev.to/szymkab/next-js-authentication-with-existing-backend-200h</link>
      <guid>https://dev.to/szymkab/next-js-authentication-with-existing-backend-200h</guid>
      <description>&lt;p&gt;Recently I was working on some Next.js project and came to issues regarding the authentication using a built-in Next.js server and the &lt;strong&gt;existing backend&lt;/strong&gt; that holds whole logic and access to a database.&lt;/p&gt;

&lt;p&gt;I had a problem with understanding how the next-auth is working and how to properly use the &lt;strong&gt;credentials&lt;/strong&gt; provider, or even if it can be used with an existing backend.&lt;/p&gt;

&lt;p&gt;So, shortly, the answer is &lt;strong&gt;yes&lt;/strong&gt;! You can use the credentials provider and make auth working together with an existing backend.&lt;/p&gt;

&lt;p&gt;In this post, I will just focus on making auth working between the Next.js server and the existing API. If you need to set up the auth in the Next.js app from scratch, please follow the docs mentioned below.&lt;/p&gt;

&lt;h2&gt;
  
  
  Basics
&lt;/h2&gt;

&lt;p&gt;Before I proceed to Next.js and auth itself I just want to mention that it would be good if you understand the basics correctly. I've prepared the list of links with useful content:&lt;/p&gt;

&lt;p&gt;Next.js:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://nextjs.org/docs"&gt;https://nextjs.org/docs&lt;/a&gt; - Next.js docs&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://next-auth.js.org/getting-started/introduction"&gt;https://next-auth.js.org/getting-started/introduction&lt;/a&gt; - next-auth docs&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://next-auth.js.org/providers/credentials"&gt;https://next-auth.js.org/providers/credentials&lt;/a&gt; - next-auth credentials provider description&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;JWT:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://youtu.be/7Q17ubqLfaM"&gt;https://youtu.be/7Q17ubqLfaM&lt;/a&gt; - quick explanation about the JWT&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Credentials provider
&lt;/h2&gt;

&lt;p&gt;Next-auth lib gives various providers to authenticate against but we are interested in the classic one, just with the username and email. In fact, it doesn't care if you are using an existing backend or do all the auth stuff in the Next.js server (but in that case you should think about a different provider).&lt;/p&gt;

&lt;p&gt;So, as the docs stand, the first thing you need to do is a setup of provider:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;providers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="nx"&gt;Providers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Credentials&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Credentials&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;credentials&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;username&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Username&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;placeholder&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;jsmith&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="na"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  &lt;span class="na"&gt;label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Password&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;password&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nx"&gt;authorize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;credentials&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// Here call your API with data passed in the login form&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;loginEndpoint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;credentials&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In &lt;code&gt;authorize()&lt;/code&gt; handler you need to make a request to your API to auth the user and if credentials are correct you can return the response (or directly the token).&lt;/p&gt;

&lt;p&gt;And now you need to set up the &lt;code&gt;jwt()&lt;/code&gt; callback. It can look like that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;callbacks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nx"&gt;jwt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;prevToken&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Initial call&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;accessToken&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Subsequent calls&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;prevToken&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This should work fine. But there is one issue.&lt;/p&gt;

&lt;h2&gt;
  
  
  Expired token issue
&lt;/h2&gt;

&lt;p&gt;The token you get from your API is not refreshed. So, you can have a situation when auth between the &lt;strong&gt;Next.js client&lt;/strong&gt; and &lt;strong&gt;Next.js server&lt;/strong&gt; works fine but the token you have from your API has &lt;strong&gt;expired&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;So, to make requests from the client through the Next.js server to your API, you would need to logout and login once again to have a valid token.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;You can't just set the options of &lt;code&gt;session.maxAge&lt;/code&gt; to match the one from the API you are using because every time you access the site (assuming you are using next-auth) time of the session is automatically extended.&lt;/p&gt;

&lt;p&gt;However, what you can do is, &lt;strong&gt;manually set the expired time&lt;/strong&gt; by hardcoding a value or returning the expired time value from the login/refresh endpoint. See how the code looks in that case:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;refreshAccessToken&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;prevToken&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;refreshEndpoint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;prevToken&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// Do what you want&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;accessToken&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;accessToken&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;accessTokenExpires&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;expiresIn&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;callbacks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nx"&gt;jwt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;prevToken&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Initial call&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;accessToken&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;accessToken&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="c1"&gt;// Assuming you can get the expired time from the API you are using&lt;/span&gt;
        &lt;span class="c1"&gt;// If not you can set this value manually&lt;/span&gt;
        &lt;span class="na"&gt;accessTokenExpires&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;expiresIn&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Subsequent calls&lt;/span&gt;
    &lt;span class="c1"&gt;// Check if the expired time set has passed&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;prevToken&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;accessTokenExpires&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// Return previous token if still valid&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;prevToken&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Refresh the token in case time has passed&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;refreshAccessToken&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;prevToken&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, in the initial call, you need to set the expired time based on what the API returns or just hardcode the value (e.g. &lt;code&gt;30 * 30&lt;/code&gt; - 1 hour). &lt;/p&gt;

&lt;p&gt;Then, whenever the session is checked &lt;code&gt;jwt()&lt;/code&gt; callback is called and the current time is compared to expired. If it's passed then you need to call the &lt;code&gt;refreshAccessToken&lt;/code&gt; function, in which you can refresh the token using the API, otherwise, the previous token is returned because it still can be used.&lt;/p&gt;

&lt;p&gt;With this approach, you can use &lt;strong&gt;the Next.js server as a proxy&lt;/strong&gt; between the client app and the API you are using. This can be very useful due to the power of Next.js API Routes.&lt;/p&gt;

&lt;p&gt;If you have any questions, let me know in the comments.&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>nextauth</category>
      <category>authentication</category>
      <category>credentials</category>
    </item>
    <item>
      <title>What is CreateJS?</title>
      <dc:creator>Szymon Kabelis</dc:creator>
      <pubDate>Mon, 16 Nov 2020 11:24:57 +0000</pubDate>
      <link>https://dev.to/szymkab/what-is-createjs-1o28</link>
      <guid>https://dev.to/szymkab/what-is-createjs-1o28</guid>
      <description>&lt;p&gt;I bet you have probably never heard about the CreateJS library, if so, this post is for you.&lt;/p&gt;

&lt;h1&gt;
  
  
  What is CreateJS?
&lt;/h1&gt;

&lt;p&gt;So… let me explain. CreateJS is a suit that consists of 4 JS libraries (can be run together or independently):&lt;/p&gt;

&lt;p&gt;– &lt;strong&gt;EaselJS&lt;/strong&gt; – all you need for generating graphics and interact with HTML5 Canvas.&lt;br&gt;
– &lt;strong&gt;TweenJS&lt;/strong&gt; – all you need for tweening things.&lt;br&gt;
– &lt;strong&gt;SoundJS&lt;/strong&gt; – all you need for playing sound.&lt;br&gt;
– &lt;strong&gt;PreloadJS&lt;/strong&gt; – all you need to preload your app assets.&lt;/p&gt;

&lt;p&gt;So as you see, pretty much all you need to create a fancy game!&lt;/p&gt;
&lt;h1&gt;
  
  
  How can you use it?
&lt;/h1&gt;

&lt;p&gt;Unfortunately, the library is written in ES5, so it means you can’t just import and use it in your project. There are some ideas for updating it to ES6 but for now, we can only use the old version.&lt;/p&gt;

&lt;p&gt;I’ve created a starter project that lets you quickly check how the library works. Check it out here.&lt;/p&gt;

&lt;p&gt;So clone the repository and execute three commands in the following order (make sure you have node &amp;amp; yarn):&lt;/p&gt;

&lt;p&gt;– &lt;code&gt;yarn setup&lt;/code&gt; – this one will init a fresh repository for a new project&lt;br&gt;
– &lt;code&gt;yarn install&lt;/code&gt; – this one will install dependencies&lt;br&gt;
– &lt;code&gt;yarn start&lt;/code&gt; and boom! You should see the following page:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffrontendgamedev.com%2Fwp-content%2Fuploads%2F2020%2F10%2Fcreatejs-boilerplates-initial-screen.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffrontendgamedev.com%2Fwp-content%2Fuploads%2F2020%2F10%2Fcreatejs-boilerplates-initial-screen.png" alt="CreateJS Boilerplate’s initial screen"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Editing the code
&lt;/h1&gt;

&lt;p&gt;Once it’s started, you can edit whatever you want for testing. For example, open the app.js file and try to change the text background color. All you need is to change the HEX color string at line 26. For example to #ff0000:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;25    const graphics = new Graphics()
26      .beginFill("#ff0000")
27      .drawRect(CONFIG.canvasWidth / 2, CONFIG.canvasHeight / 2, 380, 100);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s see what happens:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffrontendgamedev.com%2Fwp-content%2Fuploads%2F2020%2F10%2Fcreatejs-boilerplates-initial-screen-step-2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffrontendgamedev.com%2Fwp-content%2Fuploads%2F2020%2F10%2Fcreatejs-boilerplates-initial-screen-step-2.png" alt="CreateJS Boilerplate’s initial screen with red text background"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Oops! The text is not really visible now. Try to change the third argument in the Text call on line 32 to #ffffff:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;32 const welcomeText = new Text("CreateJS Boilerplate", "26px Courier", "#ffffff");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffrontendgamedev.com%2Fwp-content%2Fuploads%2F2020%2F10%2Fcreatejs-boilerplates-initial-screen-step-3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ffrontendgamedev.com%2Fwp-content%2Fuploads%2F2020%2F10%2Fcreatejs-boilerplates-initial-screen-step-3.png" alt="CreateJS Boilerplate’s initial screen with changed text and background colors"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;Even though it is not the newest and fresh library, you should give it a try!&lt;br&gt;
Come back later for more materials about that. Good luck with coding :).&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>canvas</category>
      <category>createjs</category>
      <category>es6</category>
    </item>
  </channel>
</rss>
