Precarious means that it is dangerously about to collapse. Not so stable or secure.
He was balanced precariously on top of the fence. The rock was precariously balanced on the edge of the cliff.
The schoolbus balanced precariously on the edge of the cliff.
The boat rocked precariously when my sister jumped into it.
She clung precariously to the ledge, trying not to slip off the edge.
The word precariously, like most words that end in -ly, is an adverb.
Dangerously
His book was balanced precariously on the edge of the table, with only half of it actually on the surface.
The girl was dancing precariously, as it seemed like she may fall off the edge of the stage. Luckily, she did not, and the show continued on.
Although many trees have been removed from homes and businesses, others remain precariously on the brink of falling. A bus accident that wiped out a highway safety barrier left tourist suspended precariously on the highway and the edge of a cliff
Precarious is the adjective form.
Kristina, Madison, and Emma have a relationship with insects that is quite precarious.
The idiom you have alluded to means to be placed precariously or unfavourably in a situation. The American expression "skating on thin ice" has a meaning that is synonymous and can be used interchangeably with the idiom in question.