Force a page to appear as the first and only screen on the navigation stack, with no back button:
<%= native_presentation_tag :root %>
import { NativePresentation } from "@ruby-native/react"
export default function Account() {
return (
<>
<NativePresentation intent="root" />
...
</>
)
}
<script setup>
import { NativePresentation } from "@ruby-native/vue"
</script>
<template>
<NativePresentation intent="root" />
...
</template>
Do not put this inside a cache block:
<%# Don't do this %>
<% cache @account do %>
<%= native_presentation_tag :root %>
<% end %>
The tag uses a response header to signal to the native app. Caching this call would render the HTML element but not set the header. If you need the page cached, set the header from the controller instead:
class AccountsController < ApplicationController
after_action -> { response.headers["Native-Presentation"] = "root" }, only: :show
end
A /new or /edit page is presented as a sheet in Advanced Mode, and a sheet cannot be a stack root, so the tag is ignored. A form that lands as a root is the redirect after the form, not the form itself.