useTitle

Reactive document title.

Usage

<script>
  import { useTitle } from '@svelte-use/core'

  const title = useTitle()
  console.log($title) // print current title
  $title = 'Hello' // change current title
</script>

Set initial title immediately

<script>
  const title = useTitle('New Title')
</script>

Type Declarations

export interface UseTitleOptions extends ConfigurableDocument {
  /**
   * Observe `document.title` changes using MutationObserver
   *
   * @default false
   */
  observe?: boolean
}
declare type Title = string | null | undefined
/**
 * Reactive document title.
 *
 * @see https://svelte-use.vercel.app/core/useTitle
 * @param newTitle
 * @param options
 */
export declare function useTitle(
  newTitle?: MaybeWritable<Title>,
  options?: UseTitleOptions
): Writable<Title>
export {}

Source

SourceDemoDocs