<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "visionOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/onWorldRecenter(action:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE15onWorldRecenter6actionQryyScMYcc_tF::OverloadGroup"
  },
  "title" : "onWorldRecenter(action:)"
}
-->

# onWorldRecenter(action:)

Adds an action to perform when recentering the view with the
digital crown.

```
nonisolated func onWorldRecenter(action: @escaping @MainActor () -> Void) -> some View
```

## Parameters

`action`

A closure to run when the view is recentered. This will run
when the app has been recentered and is about to fade back in,
equivalent to `WorldRecenterPhase.ended`.

## Discussion

```
struct ContentView: View {
    @State private var mascot = Mascot()
    var body: some View {
        WelcomeView(mascot: mascot)
            .onWorldRecenter {
                mascot.wave()
            }
    }
}
```

When the user recenters their view, the app will fade out and then be
repositioned. Once it has been repositioned, the action will be called
and the app will fade back in. The action will be called if the app
is not backgrounded or suspended.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)