The present invention relates to a nanocomposite ocular device that can release drugs within a close distance to the ocular surface and provide controlled and sustained release of the drug at a constant rate. The device can achieve both optical and medical functions. The device comprises a drug, one or more reservoir domains, and a barrier layer configured to block the drug diffusion paths from the reservoir domain to the ocular surface in the eye of the subject, wherein the drug partitions between the reservoir domain and the barrier layer, and the equilibrium drug solubility in the reservoir domain is at least five folds higher than that in the barrier layer.