Valheim is a great game and can be made even better with console commands. Console commands, commonly referred to as cheats, are used to instantly spawn items, change settings, and more.
Console commands are only available in the PC version of the game.

In order to use commands, you need to enable the console. How exactly to do this depends on whether you play through Steam or Game Pass (Windows Store). Instructions for both platforms are below:
If you have already enabled the console, just press F5 on the keyboard to open it. Then press the key ENTER on the keyboard after entering the console command to run it.
How to enable and use the console on Steam
To enable the console on Steam, right-click on the game in your library and select "Properties":

On the properties screen, enter the parameter -console in the "Launch Options" text box, as shown in the screenshot below:

You can then close this window and launch Valheim. The console opens in the game by pressing the button F5.
How to enable and use your console in Game Pass (Windows Store)
To enable the console in the Game Pass version of Valheim, navigate to the folder where the game is installed. It is usually located at:
C:\XboxGames\Valheim\Content
Right-click on the "Valheim.exe" file (it might just be "Valheim" on your computer) and select "Create Shortcut":

Drag the shortcut to your desktop (or wherever you like):

Right click on the shortcut and select "Properties":

Here, in the "Object" field, add the value "-console" (without quotes) at the end, as shown in the screenshot below. Then press the buttons apply и OK:

Now launch the game from this shortcut (and not directly from Game Pass) and you will be able to use the console in the game by opening it with the key F5.