Reflex Logo
Docs Logo
Library

/

Other

/

Script

The Script component can be used to include inline javascript or javascript files by URL.

It uses the next/script component to inject the script and can be safely used with conditional rendering to allow script side effects to be controlled by the state.

Complex inline scripting should be avoided. If the code to be included is more than a couple lines, it is more maintainable to implement it in a separate javascript file in the assets directory and include it via the src prop.

This component is particularly helpful for including tracking and social scripts. Any additional attrs needed for the script tag can be supplied via custom_attrs prop.

This code renders to something like the following to enable stat counting with a third party service.

API Reference

rx.script

Wrapper for the script element.

PropType | ValuesDefault
access_key
str
-
auto_capitalize
"off" | "none" | ...
-
content_editable
Union["inherit" | "plaintext-only", bool]
-
context_menu
str
-
dir
str
-
draggable
bool
-
enter_key_hint
"enter" | "done" | ...
-
hidden
bool
-
input_mode
"none" | "text" | ...
-
item_prop
str
-
lang
str
-
role
"alert" | "alertdialog" | ...
-
slot
str
-
spell_check
bool
-
tab_index
int
-
title
str
-
async_
bool
-
char_set
str
-
cross_origin
"anonymous" | "use-credentials" | ...
-
defer
bool
-
integrity
str
-
referrer_policy
"" | "no-referrer" | ...
-
src
str
-
type
str
-

Built with Reflex