Instant Database Write on Checkbox Selection

I have a checkbox test_mode which when the user toggles the value, I want the database to be updated immediately, without any submit buttons being pressed.

So to do it I’ve created a form, an update_test_mode Server Action, and I Submit the form onclick of the checkbox being clicked.

It works well, but seems quite a lot of effort for such a simple task.

Did I miss an easier way to do it?

Best wishes,
Antony.

Community Page
Last updated: