npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@jspsych-contrib/plugin-redirect-to-url

v1.0.0

Published

Facilitates redirecting to a URL at the end of a study. For example, this can facilitate running Prolific or other paid recruitment platforms.

Readme

plugin-redirect-to-url

Overview

The redirect-to-url plugin is designed to smoothly redirect participants to an external URL after a trial or at the end of an experiment. This is especially useful when integrating with participant recruitment or compensation platforms such as Prolific or MTurk. The plugin optionally displays an HTML stimulus along with one or more response buttons. When a participant clicks one of the buttons, the plugin records their response and response time, disables further input, and then redirects the browser to a specified URL. You can configure whether the redirection should occur in the current tab or open a new tab, and whether the redirection should also terminate the jsPsych experiment (abort_on_submit) or allow it to continue after saving the response. The plugin also supports fully customizable HTML button rendering via a user-defined function.


Loading

Using the CDN-hosted JavaScript file:

<script src="https://unpkg.com/@jspsych-contrib/[email protected]"></script>

Using NPM:

npm install @jspsych-contrib/plugin-redirect-to-url
import jsPsychRedirectToUrl from "@jspsych-contrib/plugin-redirect-to-url";

Compatibility

  • jsPsych version: v8.0.0 or later

Parameters

| Name | Type | Default | Description | | ----------------- | ---------------- | ------------- | ------------------------------------------------------------------------------------------- | | stimulus | HTML string | null | Optional stimulus (e.g., message or instructions) displayed above the buttons. | | choices | Array of strings | undefined | Labels for the response buttons. | | button_html | Function | (see below) | Function returning the HTML for each button. | | url | String | undefined | The URL to which the participant will be redirected. | | abort_on_submit | Boolean | true | Whether to immediately end the experiment before redirecting (recommended at end of study). | | open_in_new_tab | Boolean | false | Whether to open the URL in a new browser tab. | | end_message | HTML string | null | If abort_on_submit is true AND open_in_new_tab is true, this parameter specifies a message to display on the screen after the experiment is over. Can include HTMLformatting. | | automatically_redirect | Boolean | false | If true, the trial will automatically redirect to the specified URL without waiting for participant input. |

Default button_html function:

function (choice: string, choice_index: number) {
  return `<button class="jspsych-btn">${choice}</button>`;
}

Data Generated

| Name | Type | Description | | ---------- | ------- | ----------- | | stimulus | String | The HTML string shown above the buttons. | | rt | Integer | Time (in ms) from trial start to participant's button response. | | response | Integer | Index of the button clicked (0-indexed from choices array). |


Example

const redirect_trial = {
  type: "redirect-to-url",
  stimulus: "<p>Thank you for participating!</p>",
  choices: ["Click to complete study"],
  url: "https://app.prolific.co/submissions/complete?cc=1234ABC",
  abort_on_submit: true,
  open_in_new_tab: false,
};

Notes

  • The abort_on_submit flag is particularly useful if you do not want to show jsPsych’s end-of-experiment screen.
  • If open_in_new_tab is true, behavior may depend on the participant’s browser settings.

Author / Citation

Courtney B. Hilton
If you use this plugin in your research, please cite the corresponding repository or paper when available.