Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

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

Merged
merged 11 commits into from
Sep 4, 2022

Conversation

danielroe
Copy link
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:

import type { RouterConfig } from '@nuxt/schema'
import { createMemoryHistory } from 'vue-router'

export default <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.

@danielroe danielroe 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 pi0 September 1, 2022 08:31
@danielroe danielroe self-assigned this Sep 1, 2022
@netlify
Copy link

netlify bot commented Sep 1, 2022

βœ… Deploy Preview for nuxt3-docs ready!

Name Link
πŸ”¨ Latest commit 4fc9305
πŸ” Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/631456a55cc42c0009359839
😎 Deploy Preview https://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
Copy link
Member

pi0 commented Sep 1, 2022

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
Member Author

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
Copy link
Member

pi0 commented Sep 3, 2022

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

@pi0 pi0 changed the title feat(nuxt): allow fully overriding router history and routes feat(nuxt): support custom history and routes for app/router.optionc Sep 4, 2022
@pi0 pi0 changed the title feat(nuxt): support custom history and routes for app/router.optionc feat(nuxt): support custom history and routes for app/router.options.ts Sep 4, 2022
@pi0 pi0 changed the title feat(nuxt): support custom history and routes for app/router.options.ts feat(nuxt): custom history and routes for app/router.options.ts Sep 4, 2022
@pi0 pi0 merged commit 720506d into main Sep 4, 2022
@pi0 pi0 deleted the feat/custom-router branch September 4, 2022 07:42
@pi0 pi0 mentioned this pull request Sep 9, 2022
@pi0 pi0 mentioned this pull request Sep 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3.x enhancement New feature or request 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants