Skip to main content
Code Screens enable you to seamlessly integrate custom native SwiftUI views into your remotely configured Muta flows. This powerful feature allows you to combine the flexibility of no-code flow management with the full capabilities of native development.

Overview

Code Screens act as placeholders in your Muta flows that are replaced with native SwiftUI views at runtime. This enables you to:
  • Add authentication screens to your onboarding flows
  • Integrate payment processing directly in your flows
  • Include complex native UI that requires custom logic
  • Maintain remote configurability while using native code

How It Works

1

Create a Code Screen

In the Muta web editor, add a “Code Screen” to your flow and give it a unique name (e.g., “Login Screen”, “Payment Form”)
2

Configure Navigation

Set up the continue and back navigation destinations for your code screen
3

Inject Components

Pass your SwiftUI views when displaying the placement in your app

Implementation

Basic Setup

Pass your custom views when calling displayPlacement:

Component Interface

Your injected views receive a CodeScreenContext with the following properties:

Example Component

Here’s a complete example of a login screen component:

Animations

Code screens automatically animate in and out matching your flow’s configured animations:
  • Entry Animation: Matches the animation used when navigating TO the code screen
  • Exit Animation: Uses the configured continue/back animation settings
  • Seamless Transitions: Native screens blend smoothly with your flow screens

Use Cases

Authentication Flows

Integrate login, signup, or authentication screens directly into your onboarding:

Payment Integration

Add payment processing without breaking the flow experience:

Complex Forms

Handle multi-step forms or complex data entry:

Best Practices

  • Use descriptive, unique names for your code screens
  • Keep names consistent between the Muta editor and your code
  • Avoid special characters in screen names
  • Always handle errors gracefully in your views
  • Provide clear feedback to users
  • Consider offering retry options for network failures
  • Keep views lightweight and focused
  • Avoid heavy computations in body methods
  • Use @State and @Binding appropriately

Events

When code screens are displayed or interacted with, the SDK emits specific events:

Troubleshooting

Screen names must match exactly between the Muta editor and your injected screens configuration. A mismatch will result in the code screen not displaying.

Common Issues

Code screen not appearing:
  • Verify the screen name matches exactly (case-sensitive)
  • Ensure the view is properly wrapped in AnyView
  • Check that injectedScreens is passed to displayPlacement
Navigation not working:
  • Confirm you’re calling onContinue() or onBack()
  • Check that navigation destinations are configured in the editor
  • Ensure no SwiftUI errors are preventing execution
Animation issues:
  • Verify presentationType is set appropriately
  • Check that animation durations are reasonable (200-500ms)
  • Ensure views render quickly to avoid animation lag

Advanced Usage

Accessing Flow Variables

Code screens can read and react to flow variables:

Sequential Code Screens

You can navigate directly from one code screen to another:
The SDK handles transitions smoothly between consecutive code screens without any special configuration.