Skip to content
Discussion options

You must be logged in to vote

You can set a custom user agent for native mode via start_args:

#!/usr/bin/env python3
from fastapi import Request
from nicegui import app, ui

def root(request: Request):
    user_agent = request.headers.get('user-agent', '').lower()

    if 'pywebview' in user_agent:
        ui.label('✓ Native app detected').classes('text-green text-2xl')
    else:
        ui.label('✗ Regular browser detected').classes('text-blue text-2xl')

app.native.start_args['user_agent'] = 'NiceGUI-Native/1.0 (pywebview)'
ui.run(root, native=True)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ZeroPoint095
Comment options

Answer selected by ZeroPoint095
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants