Source code of native widgets

How do you want to extend the references extension?

The UI extension SDK as functions which allow you to show the select entry dialog (there’s also select entries, select asset, select assets) that’s pretty easy to use. Something like:

extension.dialogs.selectSingleAsset().then((asset) => {
  if (asset) {
    // do something with asset -- asset.fields.file[extension.field.locale].url
  }
});

Setting references is also pretty easy, like so:

extension.field.setValue(
  {sys: {
    type: 'Link', 
    linkType: 'Entry', 
    id: 'id_of_linked_entry'
  }
})

edit: I see what you want to do now: How to restrict entry to be referenced only once