NEW YORK used to be a second-string city when it came to coffee. No longer.

Over the last two years, more than 40 new cafes and coffee bars have joined a small, dedicated group of establishments where coffee making is treated like an art, or at least a high form of craft.

At places like Bluebird Coffee Shop in the East Village, the espresso is so plush and bright that it tastes sweet on its own.

The elaborate designs in the cappuccino’s foam at Third Rail Coffee in the West Village aren’t just to show off, but are a sign that the barista properly steamed the milk so that it holds its form.

At Abraço in the East Village, you can get drip coffee brewed by the cup, not drawn from an urn.

For years New Yorkers had to look to places like Stumptown Coffee Roasters in Portland, Ore., or Blue Bottle Coffee in San Francisco for this kind of quality. Now both companies have opened roasters and coffee bars in New York. Four Barrel Coffee of San Francisco will be roasting here soon.