Examples
Basic

Basic example

⚠️

Make sure you are using .coerce for numbers, dates, etc.

const { data, setState } = useUrlState(
  z.object({
    search: z.string(),
    limit: z.coerce.number(),
    from: z.coerce.date().optional(),
  }),
);
 
return (
  <Button
    onClick={() =>
      setState({
        search: 'query',
        limit: 10,
        from: new Date(),
      })
    }
  >
    Set the state
  </Button>
);
State
null