The only lag-free way to do that, Target Display Mode (TDM), is not supported on 2017 iMacs nor any Mini made after 2019. The very restrictive hardware and operating system conditions that TDM required are laid out here:
Use your iMac as a display with target display mode - Apple Support
Apple started the depreciation of TDM 10 years ago and threw the last shovel of dirt in its face in early 2020.
There are third-party "solutions" but they are mostly laggy. One, Luna Display, goes as far as placing this disclaimer on its main support page:
The red is their emphasis, not mine.
That says to me that it is unsuitable for making an iMac a primary display.
"On another forum somebody suggested..."
I'm sure they did. We see that misinformation a lot about iMacs being the wunderkind of computers. It started with the work-from-home requirements forced by COVID. Web writers, lacking editorial assistance and, it seems, the research skill to take two minutes to look up the Apple support article linked above, wrote thousands of articles claiming that any iMac and TDM could dot everything form working with any non-Apple device to parting the Red Sea.
A decent free-standing eternal monitor will always work best without lag, use less power, and allow full display options.