Updated:

Give a custom rocket

VersionRed large ball fading to yellow
Java 1.20.5+/give @p minecraft:firework_rocket[fireworks={flight_duration:2,explosions:[{shape:"large_ball",colors:[I;16711680],fade_colors:[I;16776960],has_trail:true,has_twinkle:true}]}]
Java 1.20.4 and earlier/give @p minecraft:firework_rocket{Fireworks:{Flight:2,Explosions:[{Type:1,Colors:[I;16711680],FadeColors:[I;16776960],Trail:1b,Flicker:1b}]}}

1.20.5 switched items from NBT in braces to components in square brackets and renamed the fields. Using the wrong format gives an error or a rocket that does not explode.

Field names

1.20.5+OlderMeaning
flight_durationFlightHeight (1–3); also elytra boost length
shapeTypeExplosion shape
colorsColorsExplosion colors
fade_colorsFadeColorsColors it fades to (optional)
has_trailTrailSparkle trail (like adding a diamond)
has_twinkleFlickerCrackle (like adding glowstone dust)

Shapes

Shape1.20.5+Older
Small ballsmall_ball0
Large balllarge_ball1
Starstar2
Creepercreeper3
Burstburst4

Color numbers

ColorNumber
Red16711680
Green65280
Blue255
Yellow16776960
White16777215
Pink16738740

The number is red × 65536 + green × 256 + blue. Orange (255, 128, 0) is 16744448. List several as [I;16711680,255] to mix colors; the I; is required.

Launch one on the spot

/summon minecraft:firework_rocket ~ ~ ~ {LifeTime:30,FireworksItem:{id:"minecraft:firework_rocket",count:1,components:{"minecraft:fireworks":{explosions:[{shape:"star",colors:[I;65280]}]}}}}

A green star bursts above the command's position (1.20.5+). LifeTime is the time in ticks before it explodes. Put it in a command block behind a button for a firework launcher. On 1.20.4 and earlier the item uses Count:1b,tag:{Fireworks:{Explosions:[{Type:2,Colors:[I;65280]}]}}.

Elytra rockets

/give @p minecraft:firework_rocket[fireworks={flight_duration:3}] 64

With no explosions, the rocket does no damage, which is what you want for elytra flight. Rockets with explosions hurt you when used for flying.

Common problems

Check your command

The Command Error Doctor checks common syntax mistakes in your browser.