LWC Community recordId undefined

From docs, you have to add <target>lightning__RecordPage</target> in the lwc component meta, for it to accept recordId from the detail page.

<targets>
    <target>lightning__RecordPage</target>
</targets>
Indicates that the component takes a record Id as an attribute.

EDIT: Apparently this works in App builder, but in communities, things are a bit funny.

You have to explicitly expose the recordIdusing <targetConfigs>

    <targetConfigs>
        <targetConfig targets="lightningCommunity__Default">
            <property name="recordId" type="String" ></property>
        </targetConfig>
    </targetConfigs>

Then in community builder provide the recordId as {!recordId}