DanF's answer is the correct answer, and should be accepted, but looking at the comments, I think there's some valuable context that might be missing, that I can add.
A typical dapp consists of a number of layers, which don't need to know much about the layers above or below them. Most dapps will use a library that provides a nice interface to the ethereum blockchain, such as Web3, truffle-contract or EthJS (although this is optional, and it's perfectly possible to write a dapp that doesn't use any of these libraries, and just uses lower-level interfaces). These libraries don't typically have the ability to access the blockchain directly (this is a slight lie - they often have helpers for local development, but it's close enough for most purposes), so need to have a low-level "provider" made available, that gives them access to the blockchain. MetaMask is such a provider.
In the early days, most dapp browsers (including MetaMask, Mist and Parity) worked by making a copy of Web3 available to dapps (by adding a
web3 object to
window), rather than making this provider available directly. Dapps that wanted to use other libraries, so needed to get at the underlying provider, would typically get hold of it with
As time's gone on, it's become clear that even if you intend to use Web3 as your library of choice, it's a good idea to import Web3 into your dapp yourself (the same way you'd import any other library - Webpack or Parcel or SystemJS or Bower or plain ol' script tags pointing to a CDN), and initialise it with the provider from
window.web3.currentProvider. This way, you always know what version of Web3 you're using, and aren't surprised by breaking API changes.
But if dapps are only using
window.web3 to get at
window.web3.currentProvider, then what's the point in including the rest of Web3 in
window.web3? Not much. So MetaMask is planning (at some point) to change
window.web3 from being a full copy of Web3, to just being a stub that provides
If you're still using the copy of Web3 provided by
window.web3 at that point, then your code will no longer work. However, if you follow the instructions that DanF linked to to obtain a provider, and then follow the instructions for your library of choice from there on out, then it will work with current and future versions of MetaMask (as well as Parity and Mist, which I believe follow the same convention).