Peel (optional) and grate potatoes on a coarse grater; grate the onion if using.
Place grated potatoes in a clean kitchen towel or fine sieve and squeeze out as much liquid as possible.
Transfer dried potatoes to a bowl, season with salt and pepper, and add flour or beaten egg if you want firmer patties.
Heat a large nonstick or cast-iron skillet over medium-high heat and add oil; swirl to coat.
Test oil heat with a small pinch of potato — it should sizzle immediately.
For patties: form even-size rounds (about 3–4 inch) by pressing a portion between palms; for loose hash, spread evenly in the pan.
Place potato rounds or loose shreds in the hot pan without crowding; press gently with a spatula to compact.
Cook undisturbed 4–6 minutes until the underside is deep golden brown and releases easily.
Flip carefully and cook another 4–6 minutes until both sides are crisp and cooked through.
Drain on paper towels to remove excess oil, sprinkle with salt, garnish with chives or parsley and serve immediately.