Basically you need to get the width and height of the device screen. Subsequently, just resize the canvas accordingly in your Javascript. Example:
var width = (window.innerWidth > 0) ? window.innerWidth : screen.width;
var height = (window.innerHeight > 0) ? window.innerHeight : screen.height;
var canvas = document.getElementById("canvas");
canvas.width = width;
canvas.height = height;
You may have screens with different resolution coefficients, although in this case I usually do a calculation of my original width and the width coefficient of the device, and then change both the width and the height accordingly. Example:
var originalWidth = 960;
var width = (window.innerWidth > 0) ? window.innerWidth : screen.width;
var widthRatio = originalWidth / width;
canvas.width *= widthRatio;
canvas.height *= widthRatio;
, , .