JSFiddle - React, Tailwind, and code Playground

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.12.1/ol.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.12.1/ol.css">

<head lang="en">
    <title>Layer Attributes</title>
</head>
<body>
<div id="map" class="map"></div>
</body>

JavaScript

var feature = new ol.Feature({
    customAttr: 'Abcd'
});

var layer = new ol.layer.Tile({
    source: new ol.source.Vector({
    features:feature
    }),
    customAttr: 'unique_id'
    
});


    var map = new ol.Map({
        layers: [
            layer
        ],
        target: 'map',
        view: new ol.View({
            center: ol.proj.fromLonLat([103.986908, 1.353199]),
            rotation: 68*Math.PI/180,
            zoom: 18
        })
    });
    
    
  map.on('click', function(evt)
    {
    debugger
        map.getLayers().forEach(function(layer){
        debugger
            alert(layer.get("customAttr"));
        });
    });