AFAICT the nRF52840 does have a BackupRAM feature, but it might not have been implemented or just wasn’t documented yet.
It’s still worth a try - unfortunately, I haven’t got a device with me right now to test , but this code builds without errors
const int LED = D7;
retained int x;
void setup() {
pinMode(LED, OUTPUT);
digitalWrite(LED, (x == 123));
x = 123;
}