Skip to content

useUrl #770

@huseeiin

Description

@huseeiin

Describe The Problem To Be Solved

on the server getRequestEvent() has Request.url but its not a convenient URL object, and on the client we have location which is not exactly the same as URL

Suggest A Solution

import { getRequestEvent, isServer } from "solid-js/web";

function useUrl() {
  return new URL(isServer ? getRequestEvent()!.request.url : location.href);
}

should this be added? just a suggestion!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions