sveltejs / sveltejs/kit

Pass the locals to the client side init function

Open
#14,696 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the problem

I connect to a SurrealDB instance using my client-side init hook. This instance uses JWT-based authentication. Therefore, I need to obtain a token from my authentication provider. I already do this at the back end via the hooks and pass the token to the client via event.locals. Ideally, I would like this data to be available in the client-side init function so that I do not need to obtain the token again on the client.

Describe the proposed solution

Change ClientInit so that it gets the locals as a parameter.

Alternatives considered

No response

Importance

would make my life easier

Additional Information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the ClientInit definition and the existing path that makes event.locals available to client code. Trace how the client-side init function is called and determine the related tests or fixtures. Done means the init function receives the locals needed for the JWT flow without requiring the token to be obtained again on the client.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.