JSFiddle - React, Tailwind, and code Playground

HTML

<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Canvas</title>
    <link rel="stylesheet" href="style.css">
  </head>

  <body>
    <canvas id="canvas" resize="true">
      Your browser does not support HTML Canvas.
      To view this page, use a browser that supports HTML Canvas.
    </canvas>
    <script type="text/javascript" src="script.js"></script>
  </body>

</html>

CSS

html,
body,
canvas {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
}

JavaScript

const canvas = document.querySelector('#canvas')

const viewportWidth = window.innerWidth
const viewportHeight = window.innerHeight

if (canvas.getContext) {
  const context = canvas.getContext('2d')

  context.fillStyle = '#222'
  context.fillRect(0, 0, viewportWidth, viewportHeight)
}