Hierarchical porous nitrogen-rich carbon nanospheres with high and durable capabilities for lithium and sodium storage.