Skip to main content
Home Theme VS Code remix-vscode-theme Color themes used on Remix Run website and docs
remix-vscode-theme | Coding Theme
VS Code preview Full workbench mockup using this variant's colors and tokenColors.
colors Workbench UI color keys from the theme JSON colors map.
activityBar.activeBackground #3f3f3f activityBar.background #1e1e1e activityBar.dropBackground #eef2f8 activityBar.foreground #b7bcbe activityBar.inactiveForeground #6a726d activityBarBadge.background #3992ff tokenColors TextMate scopes and font styles (syntax highlighting rules).
scope foreground fontStyle comment, punctuation.definition.comment #6a726d italic variable, string constant.other.placeholder, entity.name.variable.parameter, entity.name.variable.local, variable.parameter #59a8ff — variable.other.object.property #3992ff — constant.other.color #6bd968 — invalid, invalid.illegal
Shiki preview TypeScript sample highlighted with this variant's colors and tokenColors.
remix-vscode-theme — Remix Run Dark
activityBarBadge.foreground #eef2f8
badge.background #1e1e1e
badge.foreground #b7bcbe
breadcrumb.activeSelectionForeground #eef2f8
breadcrumb.background #292929
breadcrumb.focusForeground #d0d0d0
breadcrumb.foreground #b7bcbe
breadcrumbPicker.background #292929
button.background #292929
button.foreground #eef2f8
button.hoverBackground #828282
button.secondaryBackground #d83bd2
button.secondaryForeground #eef2f8
button.secondaryHoverBackground #828282
charts.blue #3992ff
charts.foreground #b7bcbe
charts.green #6bd968
charts.lines #b7bcbe
charts.orange #d83bd2
charts.purple #d83bd2
charts.red #59a8ff
charts.yellow #fecc1b
checkbox.background #1e1e1e
checkbox.foreground #b7bcbe
debugConsole.errorForeground #59a8ff
debugConsole.infoForeground #b7bcbe
debugConsole.sourceForeground #b7bcbe
debugConsole.warningForeground #fecc1b
debugConsoleInputIcon.foreground #b7bcbe
debugExceptionWidget.background #292929
debugIcon.breakpointCurrentStackframeForeground #fecc1b
debugIcon.breakpointDisabledForeground #828282
debugIcon.breakpointForeground #59a8ff
debugIcon.breakpointStackframeForeground #d0d0d0
debugIcon.breakpointUnverifiedForeground #3f3f3f
debugIcon.continueForeground #6bd968
debugIcon.disconnectForeground #59a8ff
debugIcon.pauseForeground #3992ff
debugIcon.restartForeground #6bd968
debugIcon.startForeground #6bd968
debugIcon.stepBackForeground #d0d0d0
debugIcon.stepIntoForeground #3defe9
debugIcon.stepOutForeground #d83bd2
debugIcon.stepOverForeground #3992ff
debugIcon.stopForeground #59a8ff
debugTokenExpression.boolean #d83bd2
debugTokenExpression.error #59a8ff
debugTokenExpression.name #d83bd2
debugTokenExpression.number #d83bd2
debugTokenExpression.string #6bd968
debugTokenExpression.value #b7bcbe
debugToolBar.background #292929
debugView.stateLabelBackground #3992ff
debugView.stateLabelForeground #eef2f8
debugView.valueChangedHighlight #3992ff
descriptionForeground #6a726d
diffEditor.diagonalFill #3f3f3f
diffEditor.insertedTextBackground #6bd96820
diffEditor.removedTextBackground #59a8ff20
dropdown.background #1e1e1e
dropdown.foreground #b7bcbe
dropdown.listBackground #1e1e1e
editor.background #1e1e1e
editor.findMatchBackground #fecc1b6f
editor.findMatchHighlightBackground #d83bd26f
editor.findRangeHighlightBackground #2929296f
editor.foreground #b7bcbe
editor.hoverHighlightBackground #3f3f3f6f
editor.inactiveSelectionBackground #3f3f3f
editor.lineHighlightBackground #292929
editor.rangeHighlightBackground #2929296f
editor.selectionBackground #3f3f3f
editor.selectionHighlightBackground #292929
editor.snippetFinalTabstopHighlightBackground #6a726d
editor.snippetTabstopHighlightBackground #3f3f3f
editor.wordHighlightBackground #3f3f3f6f
editor.wordHighlightStrongBackground #6a726d6f
editorBracketMatch.background #3f3f3f
editorCodeLens.foreground #3f3f3f
editorCursor.foreground #b7bcbe
editorError.foreground #59a8ff
editorGroup.background #1e1e1e
editorGroup.dropBackground #3f3f3f6f
editorGroup.emptyBackground #1e1e1e
editorGroupHeader.noTabsBackground #292929
editorGroupHeader.tabsBackground #292929
editorGutter.addedBackground #6bd968
editorGutter.background #1e1e1e
editorGutter.commentRangeForeground #828282
editorGutter.deletedBackground #59a8ff
editorGutter.foldingControlForeground #b7bcbe
editorGutter.modifiedBackground #d83bd2
editorHint.foreground #3992ff
editorHoverWidget.background #1e1e1e
editorHoverWidget.foreground #b7bcbe
editorIndentGuide.activeBackground #828282
editorIndentGuide.background #6a726d
editorInfo.foreground #3defe9
editorLightBulb.foreground #fecc1b
editorLightBulbAutoFix.foreground #3992ff
editorLineNumber.activeForeground #828282
editorLineNumber.foreground #6a726d
editorLink.activeForeground #3992ff
editorMarkerNavigation.background #292929
editorMarkerNavigationError.background #59a8ff
editorMarkerNavigationInfo.background #3992ff
editorMarkerNavigationWarning.background #fecc1b
editorOverviewRuler.addedForeground #6bd968
editorOverviewRuler.bracketMatchForeground #d0d0d0
editorOverviewRuler.commonContentForeground #d0d0d0
editorOverviewRuler.currentContentForeground #3992ff
editorOverviewRuler.deletedForeground #59a8ff
editorOverviewRuler.errorForeground #59a8ff
editorOverviewRuler.findMatchForeground #fecc1b6f
editorOverviewRuler.incomingContentForeground #6bd968
editorOverviewRuler.infoForeground #3defe9
editorOverviewRuler.modifiedForeground #d83bd2
editorOverviewRuler.rangeHighlightForeground #6a726d6f
editorOverviewRuler.selectionHighlightForeground #3f3f3f6f
editorOverviewRuler.warningForeground #fecc1b
editorOverviewRuler.wordHighlightForeground #eef2f86f
editorOverviewRuler.wordHighlightStrongForeground #3992ff6f
editorPane.background #1e1e1e
editorRuler.foreground #6a726d
editorSuggestWidget.background #292929
editorSuggestWidget.foreground #b7bcbe
editorSuggestWidget.highlightForeground #3992ff
editorSuggestWidget.selectedBackground #3f3f3f
editorWarning.foreground #fecc1b
editorWhitespace.foreground #6a726d
editorWidget.background #1e1e1e
editorWidget.foreground #b7bcbe
errorForeground #59a8ff
extensionBadge.remoteBackground #d83bd2
extensionBadge.remoteForeground #eef2f8
extensionButton.prominentBackground #6bd968
extensionButton.prominentForeground #eef2f8
extensionButton.prominentHoverBackground #3f3f3f
foreground #b7bcbe
gitDecoration.addedResourceForeground #6bd968
gitDecoration.conflictingResourceForeground #fecc1b
gitDecoration.deletedResourceForeground #59a8ff
gitDecoration.ignoredResourceForeground #6a726d
gitDecoration.modifiedResourceForeground #d83bd2
gitDecoration.stageDeletedResourceForeground #59a8ff
gitDecoration.stageModifiedResourceForeground #d83bd2
gitDecoration.submoduleResourceForeground #d0d0d0
gitDecoration.untrackedResourceForeground #d83bd2
icon.foreground #828282
input.background #1e1e1e
input.foreground #b7bcbe
input.placeholderForeground #6a726d
inputOption.activeBackground #3f3f3f
inputOption.activeBorder #d83bd2
inputOption.activeForeground #b7bcbe
inputValidation.errorBackground #59a8ff
inputValidation.errorBorder #59a8ff
inputValidation.errorForeground #b7bcbe
inputValidation.infoBackground #3992ff
inputValidation.infoBorder #3992ff
inputValidation.infoForeground #b7bcbe
inputValidation.warningBackground #fecc1b
inputValidation.warningBorder #fecc1b
inputValidation.warningForeground #b7bcbe
list.activeSelectionBackground #3f3f3f
list.activeSelectionForeground #b7bcbe
list.dropBackground #eef2f8
list.errorForeground #59a8ff
list.filterMatchBackground #3f3f3f
list.focusBackground #3f3f3f
list.focusForeground #b7bcbe
list.highlightForeground #eef2f8
list.hoverBackground #6a726d
list.hoverForeground #b7bcbe
list.inactiveFocusBackground #3f3f3f
list.inactiveSelectionBackground #3f3f3f
list.inactiveSelectionForeground #b7bcbe
list.invalidItemForeground #59a8ff
list.warningForeground #fecc1b
listFilterWidget.background #1e1e1e
listFilterWidget.noMatchesOutline #59a8ff
menu.background #292929
menu.foreground #b7bcbe
menu.selectionBackground #3f3f3f
menu.selectionForeground #b7bcbe
menu.separatorBackground #eef2f8
menubar.selectionBackground #292929
menubar.selectionForeground #b7bcbe
merge.currentContentBackground #3992ff40
merge.currentHeaderBackground #3992ff40
merge.incomingContentBackground #6bd96860
merge.incomingHeaderBackground #6bd96860
minimap.background #1e1e1e
minimap.errorHighlight #59a8ff
minimap.findMatchHighlight #fecc1b6f
minimap.selectionHighlight #3f3f3f6f
minimap.warningHighlight #fecc1b
minimapGutter.addedBackground #6bd968
minimapGutter.deletedBackground #59a8ff
minimapGutter.modifiedBackground #d83bd2
notebook.rowHoverBackground #292929
notification.background #3f3f3f
notification.buttonBackground #3992ff
notification.buttonForeground #eef2f8
notification.buttonHoverBackground #3f3f3f
notification.errorBackground #59a8ff
notification.errorForeground #eef2f8
notification.foreground #b7bcbe
notification.infoBackground #3defe9
notification.infoForeground #eef2f8
notification.warningBackground #fecc1b
notification.warningForeground #eef2f8
notificationCenterHeader.background #292929
notificationCenterHeader.foreground #b7bcbe
notificationLink.foreground #3992ff
notifications.background #3f3f3f
notifications.foreground #b7bcbe
notificationsErrorIcon.foreground #59a8ff
notificationsInfoIcon.foreground #3992ff
notificationsWarningIcon.foreground #fecc1b
panel.background #1e1e1e
panel.dropBackground #2929296f
panelTitle.activeForeground #b7bcbe
panelTitle.inactiveForeground #6a726d
peekViewEditor.background #292929
peekViewEditor.matchHighlightBackground #d83bd26f
peekViewEditorGutter.background #292929
peekViewResult.background #1e1e1e
peekViewResult.fileForeground #b7bcbe
peekViewResult.lineForeground #6a726d
peekViewResult.matchHighlightBackground #d83bd26f
peekViewResult.selectionBackground #3f3f3f
peekViewResult.selectionForeground #b7bcbe
peekViewTitle.background #3f3f3f
peekViewTitleDescription.foreground #6a726d
peekViewTitleLabel.foreground #b7bcbe
pickerGroup.foreground #6a726d
problemsErrorIcon.foreground #59a8ff
problemsInfoIcon.foreground #3defe9
problemsWarningIcon.foreground #fecc1b
progressBar.background #6a726d
quickInput.background #292929
quickInput.foreground #b7bcbe
scrollbar.shadow #292929
scrollbarSlider.activeBackground #8282826f
scrollbarSlider.background #3f3f3f6f
scrollbarSlider.hoverBackground #6a726d6f
selection.background #3992ff
settings.checkboxBackground #292929
settings.checkboxForeground #b7bcbe
settings.dropdownBackground #292929
settings.dropdownForeground #b7bcbe
settings.focusedRowBackground #3f3f3f
settings.headerForeground #b7bcbe
settings.modifiedItemForeground #3992ff
settings.modifiedItemIndicator #3992ff
settings.numberInputBackground #292929
settings.numberInputForeground #b7bcbe
settings.textInputBackground #292929
settings.textInputForeground #b7bcbe
sideBar.background #292929
sideBar.dropBackground #3f3f3f6f
sideBar.foreground #b7bcbe
sideBarSectionHeader.background #6a726d
sideBarSectionHeader.foreground #b7bcbe
sideBarTitle.foreground #b7bcbe
statusBar.background #3992ff
statusBar.debuggingBackground #d83bd2
statusBar.debuggingForeground #eef2f8
statusBar.foreground #eef2f8
statusBar.noFolderBackground #d83bd2
statusBar.noFolderForeground #eef2f8
statusBarItem.activeBackground #6a726d
statusBarItem.errorBackground #59a8ff
statusBarItem.errorForeground #eef2f8
statusBarItem.hoverBackground #3f3f3f
statusBarItem.prominentBackground #d83bd2
statusBarItem.prominentForeground #eef2f8
statusBarItem.prominentHoverBackground #59a8ff
statusBarItem.remoteBackground #6bd968
statusBarItem.remoteForeground #eef2f8
symbolIcon.arrayForeground #b7bcbe
symbolIcon.booleanForeground #d83bd2
symbolIcon.classForeground #fecc1b
symbolIcon.colorForeground #f0f
symbolIcon.constantForeground #d83bd2
symbolIcon.constructorForeground #3992ff
symbolIcon.enumeratorForeground #d83bd2
symbolIcon.enumeratorMemberForeground #3992ff
symbolIcon.eventForeground #fecc1b
symbolIcon.fieldForeground #59a8ff
symbolIcon.fileForeground #b7bcbe
symbolIcon.folderForeground #b7bcbe
symbolIcon.functionForeground #3992ff
symbolIcon.interfaceForeground #3992ff
symbolIcon.keyForeground #f0f
symbolIcon.keywordForeground #d83bd2
symbolIcon.methodForeground #3992ff
symbolIcon.moduleForeground #b7bcbe
symbolIcon.namespaceForeground #b7bcbe
symbolIcon.nullForeground #d0d0d0
symbolIcon.numberForeground #d83bd2
symbolIcon.objectForeground #f0f
symbolIcon.operatorForeground #f0f
symbolIcon.packageForeground #f0f
symbolIcon.propertyForeground #b7bcbe
symbolIcon.referenceForeground #f0f
symbolIcon.snippetForeground #b7bcbe
symbolIcon.stringForeground #6bd968
symbolIcon.structForeground #fecc1b
symbolIcon.textForeground #b7bcbe
symbolIcon.typeParameterForeground #f0f
symbolIcon.unitForeground #f0f
symbolIcon.variableForeground #59a8ff
tab.activeBackground #1e1e1e
tab.activeForeground #b7bcbe
tab.activeModifiedBorder #3992ff
tab.hoverBackground #3f3f3f
tab.inactiveBackground #292929
tab.inactiveForeground #6a726d
tab.inactiveModifiedBorder #3992ff
tab.unfocusedActiveBackground #1e1e1e
tab.unfocusedActiveForeground #828282
tab.unfocusedActiveModifiedBorder #3992ff
tab.unfocusedHoverBackground #3f3f3f
tab.unfocusedInactiveForeground #6a726d
tab.unfocusedInactiveModifiedBorder #3992ff
terminal.ansiBlack #1e1e1e
terminal.ansiBlue #3992ff
terminal.ansiBrightBlack #6a726d
terminal.ansiBrightBlue #3992ff
terminal.ansiBrightCyan #3defe9
terminal.ansiBrightGreen #6bd968
terminal.ansiBrightMagenta #d83bd2
terminal.ansiBrightRed #59a8ff
terminal.ansiBrightWhite #eef2f8
terminal.ansiBrightYellow #fecc1b
terminal.ansiCyan #3defe9
terminal.ansiGreen #6bd968
terminal.ansiMagenta #d83bd2
terminal.ansiRed #59a8ff
terminal.ansiWhite #b7bcbe
terminal.ansiYellow #fecc1b
terminal.background #1e1e1e
terminal.foreground #b7bcbe
terminalCursor.foreground #b7bcbe
textBlockQuote.background #292929
textBlockQuote.border #3992ff
textCodeBlock.background #1e1e1e
textLink.activeForeground #3defe9
textLink.foreground #3992ff
textPreformat.foreground #3992ff
textSeparator.foreground #f0f
titleBar.activeBackground #1e1e1e
titleBar.activeForeground #b7bcbe
titleBar.inactiveBackground #292929
titleBar.inactiveForeground #6a726d
tree.indentGuidesStroke #b7bcbe
walkThrough.embeddedEditorBackground #1e1e1e
welcomePage.background #1e1e1e
welcomePage.buttonBackground #292929
welcomePage.buttonHoverBackground #3f3f3f
widget.shadow #1e1e1e invalid.deprecated #d0d0d0 —
keyword, storage.modifier #d83bd2 —
keyword.control, keyword.control.flow, keyword.control.from, keyword.control.import, keyword.control.as #d83bd2 —
keyword.other.using, keyword.other.namespace, keyword.other.class, keyword.other.new, keyword.other.event, keyword.other.this, keyword.other.await, keyword.other.var, keyword.other.package, keyword.other.import, variable.language.this, storage.type.ts #d83bd2 —
keyword.type, storage.type.primitive #3defe9 —
storage.type.function #3992ff —
constant.other.color, punctuation, punctuation.section.class.end, meta.tag, punctuation.definition.tag, punctuation.separator.inheritance.php, punctuation.definition.tag.html, punctuation.definition.tag.begin.html, punctuation.definition.tag.end.html, keyword.other.template, keyword.other.substitution #b7bcbe —
punctuation.section.embedded, variable.interpolation #d0d0d0 —
entity.name.tag, meta.tag.sgml, markup.deleted.git_gutter #59a8ff —
entity.name.function, meta.function-call, variable.function, support.function, keyword.other.special-method #3992ff —
meta.block variable.other #59a8ff —
support.other.variable, string.other.link #59a8ff —
constant.numeric, constant.language, support.constant, constant.character, constant.escape, keyword.other.unit, keyword.other #d83bd2 —
string, constant.other.symbol, constant.other.key, entity.other.inherited-class, markup.heading, markup.inserted.git_gutter, meta.group.braces.curly constant.other.object.key.js string.unquoted.label.js #6bd968
entity.name, support.type, support.class, support.other.namespace.use.php, meta.use.php, support.other.namespace.php, markup.changed.git_gutter, support.type.sys-types #fecc1b —
storage.type, storage.modifier.package, storage.modifier.import #fecc1b —
entity.name.variable.field #3992ff —
source.css support.type.property-name, source.sass support.type.property-name, source.scss support.type.property-name, source.less support.type.property-name, source.stylus support.type.property-name, source.postcss support.type.property-name #3defe9 —
entity.name.module.js, variable.import.parameter.js, variable.other.class.js #59a8ff —
variable.language #59a8ff italic
entity.name.method.js #3992ff italic
meta.class-method.js entity.name.function.js, variable.function.constructor #3992ff —
entity.other.attribute-name #3992ff —
text.html.basic entity.other.attribute-name.html, text.html.basic entity.other.attribute-name #fecc1b italic
entity.other.attribute-name.class #fecc1b —
source.sass keyword.control #3992ff —
constant.character.escape #3defe9 —
*url*, *link*, *uri* — underline
tag.decorator.js entity.name.tag.js, tag.decorator.js punctuation.definition.tag.js #3992ff italic
source.js constant.other.object.key.js string.unquoted.label.js #d83bd2 italic
source.json meta.structure.dictionary.json support.type.property-name.json #3992ff —
source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json #3992ff —
source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json #3992ff —
source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json #3992ff —
source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json #3992ff —
source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json #3992ff —
source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json #3992ff —
source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json #3992ff —
source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json #3992ff —
text.html.markdown, punctuation.definition.list_item.markdown #b7bcbe —
text.html.markdown markup.inline.raw.markdown #d83bd2 —
text.html.markdown markup.inline.raw.markdown punctuation.definition.raw.markdown #3defe9 —
text.html.markdown meta.dummy.line-break #6a726d —
markdown.heading, markup.heading | markup.heading entity.name, markup.heading.markdown punctuation.definition.heading.markdown #3992ff —
markup.italic #59a8ff italic
markup.bold, markup.bold string #59a8ff bold
markup.bold markup.italic, markup.italic markup.bold, markup.quote markup.bold, markup.bold markup.italic string, markup.italic markup.bold string, markup.quote markup.bold string #59a8ff bold
markup.underline #d83bd2 underline
markup.quote punctuation.definition.blockquote.markdown #3defe9 —
string.other.link.title.markdown #3992ff —
string.other.link.description.title.markdown #d83bd2 —
constant.other.reference.link.markdown #fecc1b —
markup.raw.block.fenced.markdown #00000050 —
punctuation.definition.fenced.markdown #00000050 —
markup.raw.block.fenced.markdown, variable.language.fenced.markdown #d83bd2 —
variable.language.fenced.markdown #59a8ff —
meta.separator #3defe9 bold
token.error-token #59a8ff —
token.debug-token #d83bd2 —
export interface User {
id : string ;
name : string ;
role : " admin " | " member " ;
tags : string [];
}
/**
* Fetch user data by ID
* @ param id
* @ returns User object or null if ID is invalid
*/
export async function fetchUser ( id : string ) : Promise < User | null > {
if ( ! id ) {
return null ;
}
const response = await fetch ( ` /api/users/ ${ id }` , {
method: " GET " ,
headers: { Accept: " application/json " },
});
if ( ! response . ok ) {
throw new Error ( ` HTTP ${ response . status }` );
}
return ( await response . json ()) as User ;
}
function greet ( user : User ) : string {
// Simple greeting function that uses the user's name
return ` Hello, ${ user . name } ! ` ;
}
Ln 5, Col 12
Spaces: 2
UTF-8
LF
TypeScript
Dark+
fetchUser.ts
index.ts
README.md
src
components
fetchUser.ts
Button.tsx
Modal.tsx
hooks
utils
index.ts
public
README.md
src
components
fetchUser.ts
fetchUser 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Problems1
Output
Debug Console
Terminal
Ports
~/my-project $ pnpm dev
▲ Next.js ready on http://localhost:3000
✓ compiled client and server successfully in 412ms
wait - compiling /theme/vscode...
~/my-project $
package.json
tsconfig.json
export interface User {
id : string ;
name : string ;
role : " admin " | " member " ;
tags : string [];
}
/**
* Fetch user data by ID
* @ param id
* @ returns User object or null if ID is invalid
*/
export async function fetchUser ( id : string ) : Promise < User | null > {
if ( ! id ) {
return null ;
}
const response = await fetch ( ` /api/users/ ${ id }` , {
method: " GET " ,
headers: { Accept: " application/json " },
});
if ( ! response . ok ) {
throw new Error ( ` HTTP ${ response . status }` );
}
return ( await response . json ()) as User ;
}
function greet ( user : User ) : string {
// Simple greeting function that uses the user's name
return ` Hello, ${ user . name } ! ` ;
}