Establishes a JSON RPC connection from a provided endpoint and returns a Connection object.
import { getRpcEndpointUrl, getNewConnection } from '@lndgalante/solutils';
const { rpcUrl } = getRpcEndpointUrl('solana', 'mainnet');
const { connection } = getNewConnection(rpcEndpointUrl);
// Then trigger any API method from connection
connection.getSlot().then((slot) => console.log(slot));
⚠️
If you're using @solana/wallet-adapter-react you have this method available in a hook form.