Preheat oven to 350°F (175°C). Grease a rimmed half-sheet pan (about 18×13 inches) with butter or nonstick spray. Line the bottom with parchment paper and lightly grease the parchment for easier removal and cleaner slices.
In a large mixing bowl or stand mixer, beat 1 cup softened unsalted butter and 2 cups granulated sugar on medium speed for 3–4 minutes, until light and fluffy, scraping down the bowl once or twice.
1 cup unsalted butter, 2 cups granulated sugar
Add the 4 large eggs one at a time, beating well after each addition. Mix in 2 teaspoons vanilla extract. The batter should look smooth and slightly thick.
4 large eggs, 2 teaspoons pure vanilla extract
In a separate bowl, whisk together 2 cups all-purpose flour, 1 teaspoon baking soda, 1/2 teaspoon baking powder, and 1/2 teaspoon fine sea salt.
2 cups all-purpose flour, 1 teaspoon baking soda, 1/2 teaspoon baking powder, 1/2 teaspoon fine sea salt
With the mixer on low, add about one-third of the dry mixture to the butter mixture and mix just until combined. Add about half of the 1 cup buttermilk and mix again. Repeat with another third of the dry ingredients, the remaining buttermilk, and then the final third of the dry mixture, mixing only until the flour just disappears to avoid overmixing.
2 cups all-purpose flour, 1 teaspoon baking soda, 1/2 teaspoon baking powder, 1/2 teaspoon fine sea salt, 1 cup buttermilk
Gently fold in 1 cup sweetened shredded coconut and 1 cup chopped pecans with a spatula until evenly distributed.
1 cup sweetened shredded coconut, 1 cup pecans
Pour the batter into the prepared half-sheet pan and spread it evenly into the corners with an offset spatula or the back of a spoon. Bake at 350°F (175°C) for 22–28 minutes, or until the top is lightly golden and a toothpick inserted in the center comes out clean or with a few moist crumbs.
Place the pan on a cooling rack and let the cake cool completely in the pan, about 45–60 minutes. Do not frost until the cake is fully cooled.
In a clean bowl, beat 8 ounces softened cream cheese and 1/2 cup softened unsalted butter on medium speed for about 2 minutes, until smooth and creamy. Add 1 teaspoon vanilla extract and 1/4 teaspoon fine sea salt and beat to combine. Gradually add 3 1/2 cups powdered sugar, mixing on low at first, then increasing to medium and beating 2–3 minutes until fluffy. Add up to an additional 1/2 cup powdered sugar if you prefer a thicker frosting.
8 ounces cream cheese, 1/2 cup unsalted butter, 1 teaspoon pure vanilla extract, 1/4 teaspoon fine sea salt, 3 1/2-4 cups powdered sugar
Once the cake is completely cool, spread the cream cheese frosting evenly over the top. Sprinkle with 1/2 cup finely chopped pecans, if using, and gently press them into the frosting so they adhere.
8 ounces cream cheese, 1/2 cup unsalted butter, 1 teaspoon pure vanilla extract, 1/4 teaspoon fine sea salt, 3 1/2-4 cups powdered sugar, 1/2 cup pecans
For the neatest bars, chill the frosted cake in the refrigerator for at least 30–60 minutes before cutting. Use a sharp knife, wiping it with a warm, damp cloth between cuts, and slice into 24–30 squares (or 35–40 mini bars for bite-sized pieces).