Valheim is a great game, and it can be made even greater with console commands. Console commands, commonly referred to as cheats, are "commands" you type into the game to spawn items, change settings, and do a lot more.
Console commands are only available for the PC edition of the game.
Before you can use commands, you'll need to enable the console. How you do this depends on whether you are playing via Steam or the Game Pass (Windows Store). See help for your platform below:
If you've already enabled the console, simply press F5 on your keyboard to open up the console. Hit the ENTER key on your keyboard after typing in a console command to run it.
How to Enable and Use the Console on Steam
To enable the console in Steam, right-click the game in your Library and select "Properties":

Once in the Properties screen, enter -console into the "Launch Options" text box, as is shown in the below image:

You can then close this window and launch Valheim. The console can be opened by pressing the F5 key.
How to Enable and Use the Console on Game Pass (Windows Store)
To enable the console in the Game Pass version of Valheim, navigate to the game's install folder. This is usually:
C:\XboxGames\Valheim\Content
Right click "Valeim.exe" (this may be just "Valheim" on your computer) and click "Create shortcut":

Drag the shortcut to your desktop (or wherever you'd like it to be):

Right click the shortcut and select "Properties":

From here, add " -console" (without quotes) to the end of the "Target:" field (shown in the below image). Then click Apply and finally OK:

Now launch the game from this shortcut (not directly from Game Pass), and you can open the console by pressing the F5 key.