Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.
/frameworkPublic archive

feat(nuxt): custom history and routes for app/router.options.ts - #7129

Merged
pi0 merged 11 commits into
mainfrom
feat/custom-router
Sep 4, 2022
Merged

feat(nuxt): custom history and routes for app/router.options.ts#7129
pi0 merged 11 commits into
mainfrom
feat/custom-router

Conversation

@danielroe

Copy link
Copy Markdown
Member

🔗 Linked issue

nuxt/nuxt#14764

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Alongside first-class 'presets' like nuxt/nuxt#14764 and nuxt/nuxt#13821 which can be configured with a string, it might be useful to allow fully overriding router history + routes for advanced use cases (= escape hatch).

This allows a router options something like this:

importtype{RouterConfig}from'@nuxt/schema'import{createMemoryHistory}from'vue-router'exportdefault<RouterConfig>{history: process.client ? createMemoryHistory : undefined}

Note that this does not replace #6980 as hash history has its own challenges with an SSR framework and needs its own implementation.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@danielroedanielroe added enhancement New feature or request 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing labels Sep 1, 2022
@danielroe
danielroe requested a review from pi0September 1, 2022 08:31
@danielroedanielroe self-assigned this Sep 1, 2022
@netlify

netlifyBot commented Sep 1, 2022

Copy link
Copy Markdown

Deploy Preview for nuxt3-docs ready!

NameLink
🔨 Latest commit4fc9305
🔍 Latest deploy loghttps://app.netlify.com/sites/nuxt3-docs/deploys/631456a55cc42c0009359839
😎 Deploy Previewhttps://deploy-preview-7129--nuxt3-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@pi0

pi0 commented Sep 1, 2022

Copy link
Copy Markdown
Member

I like the idea of being able to override history and routes via app/router.options file.

The factory function for history seems good idea too.

Maybe we can also pass default routes to a factory to allow overriding+modifiying routes from config?

(in both regards delaying this PR as well as history for after RC.9 to test better)

@danielroe

Copy link
Copy Markdown
MemberAuthor

Great. Can look into factory routes option as well 👍

Big question in my mind (regardless of the factory function point) is tree-shaking - would be nice to support tree-shaking out auto-generated routes in the event that user fully overrides them, and I'm not sure that rollup will remove them from the build as is. (But then again, nothing stopping user from removing them entirely in the pages:extend hook so maybe I'm overthinking this.)

@pi0

pi0 commented Sep 3, 2022

Copy link
Copy Markdown
Member

Agreed that hook is probably best way to override routes. Do you mind adding function support for routes() in order to merge this?

Comment threadpackages/nuxt/src/pages/runtime/router.ts Outdated
Comment threadpackages/nuxt/src/pages/runtime/router.ts Outdated
@pi0pi0 changed the title feat(nuxt): allow fully overriding router history and routesfeat(nuxt): support custom history and routes for app/router.optioncSep 4, 2022
@pi0pi0 changed the title feat(nuxt): support custom history and routes for app/router.optioncfeat(nuxt): support custom history and routes for app/router.options.tsSep 4, 2022
@pi0pi0 changed the title feat(nuxt): support custom history and routes for app/router.options.tsfeat(nuxt): custom history and routes for app/router.options.tsSep 4, 2022
pi0
pi0 approved these changes Sep 4, 2022
@pi0
pi0 merged commit 720506d into mainSep 4, 2022
@pi0
pi0 deleted the feat/custom-router branch September 4, 2022 07:42
@pi0pi0 mentioned this pull request Sep 9, 2022
@pi0pi0 mentioned this pull request Sep 15, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

3.xenhancementNew feature or request🍰 p2-nice-to-havePriority 2: nothing is broken but it's worth addressing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@danielroe@pi0