Skip to content

useNavigateToStudioDocument create new tab #674

@codercatdev

Description

@codercatdev

Is your feature request related to a problem? Please describe.
I would like to use useNavigateToStudioDocument but I often find I need to open a new tab so that my list of items I am working on doesn't disappear from my App SDK.

Describe the solution you'd like
Provide a way to open new studio in blank browser tab.

Describe alternatives you've considered

Workaround: Manually construct the URL
If you need to open in a new tab, you can construct the studio URL manually using Sanity's intent URL pattern:


function OpenInStudioNewTab({ handle }: { handle: DocumentHandle }) { 
    const handleClick = () => {
        const studioUrl = 'https://your-project.sanity.studio'
        const intentUrl = `${studioUrl}/intent/edit/id=${handle.documentId};type=${handle.documentType}`
        window.open(intentUrl, '_blank')
    }
    return <Button onClick={handleClick} text="Open in Studio (New Tab)" />
}

If you're using a self-hosted studio, use that URL. If you're using the Sanity-hosted studio, it would typically be https://.sanity.studio.
You could also get the studio URL from your configuration or environment variables to make it dynamic.

Additional context
Walking through the below tutorial and wanted this feature.
https://www.sanity.io/learn/course/build-content-apps-with-sanity-app-sdk/use-navigate-to-studio-document#s-1937fcbf0fc5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions