I am developing an application that uses the MATIC token on the MATIC network. I want to make sure the user is connected to this network with MetaMask, is this possible?
Right now in my client.js attached to my html page, I just have the following:
let accounts, web3, contract;
if (typeof window.ethereum !== 'undefined') {
console.log('MetaMask is installed!');
} else {
alert("Hello! Consider adding an ethereum wallet such as MetaMask to fully use this website.");
}
accounts = ethereum.request({ method: 'eth_requestAccounts' });
web3 = new Web3();
The issue is that if the user tries to interact with other features of the website, they could attempt to use ETH, which could make them lose their token and just not have the feature work. So I want to prompt them to get onto the MATIC network.
Is there any way to get them onto this network automatically, without having them need to put it into MetaMask manually? Would help reduce friction.

This is the MATIC network I've been using on my backend server.js for this application:
const WEB3_PROVIDER = "https://polygon-rpc.com"
// https://blog.polygon.technology/polygon-rpc-gateway-will-provide-a-free-high-performance-connection-to-the-polygon-pos-blockchain/
if (typeof web3 !== 'undefined') {
web3 = new Web3(web3.currentProvider);
console.log("web3 already initialized.");
} else {
// set the provider you want from Web3.providers
web3 = new Web3(new Web3.providers.HttpProvider(WEB3_PROVIDER));
console.log("New web3 object initialized.");
}